Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit b25464c

Browse files
author
v1rtl
committed
add new tests and fix bugs
1 parent 5b544a9 commit b25464c

18 files changed

+401
-286
lines changed

egg.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
"entry": "./app.ts",
55
"description": "0-legacy, tiny & fast web framework as a replacement of Express",
66
"homepage": "https://github.com/talentlessguy/tinyhttp-deno",
7-
"version": "0.0.19",
8-
"files": ["./*.ts", "./utils/*.ts", "./extensions/**/*.ts", "README.md"],
7+
"version": "0.0.21",
8+
"files": [
9+
"./*.ts",
10+
"./utils/*.ts",
11+
"./extensions/**/*.ts",
12+
"README.md"
13+
],
914
"checkFormat": false,
10-
"checkTests": true,
15+
"checkTests": false,
1116
"checkInstallation": false,
1217
"check": true,
1318
"unlisted": false,

extensions/res/download.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { contentDisposition } from 'https://esm.sh/@tinyhttp/content-disposition'
2-
import { SendFileOptions, sendFile } from './sendFile.ts'
2+
import { SendFileOptions, sendFile } from './send/sendFile.ts'
33
import { resolve, extname } from 'https://deno.land/std@0.88.0/path/mod.ts'
44
import { setContentType, setHeader } from './headers.ts'
55
import { Req, Res } from '../../deps.ts'

extensions/res/mod.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
export * from './end.ts'
2-
export * from './json.ts'
3-
export * from './send.ts'
4-
export * from './sendStatus.ts'
5-
export * from './headers.ts'
6-
export * from './sendFile.ts'
2+
export * from './send/mod.ts'
73
export * from './append.ts'
84
export * from './format.ts'
95
export * from './download.ts'
106
export * from './cookie.ts'
7+
export * from './headers.ts'

extensions/res/json.ts renamed to extensions/res/send/json.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export const json = <Request extends Req = Req, Response extends Res = Res>(req:
66
body: T
77
): Response => {
88
res.headers?.set('Content-Type', 'application/json')
9-
if (typeof body === 'object' && body != null) req.respond({ body: JSON.stringify(body, null, 2) })
10-
else if (typeof body === 'string') req.respond({ body })
9+
if (typeof body === 'object' && body != null) req.respond({ ...res, body: JSON.stringify(body, null, 2) })
10+
else if (typeof body === 'string') req.respond({ ...res, body })
1111
else if (body == null) {
1212
res.headers.delete('Content-Length')
1313
res.headers.delete('Transfer-Encoding')
14-
req.respond({})
14+
req.respond(res)
1515
}
1616

1717
return res

extensions/res/send/mod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './json.ts'
2+
export * from './mod.ts'
3+
export * from './send.ts'
4+
export * from './sendFile.ts'
5+
export * from './sendStatus.ts'

extensions/res/send.ts renamed to extensions/res/send/send.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Req, Res } from '../../deps.ts'
1+
import { Req, Res } from '../../../deps.ts'
22
import { json } from './json.ts'
3-
import { createETag, setCharset } from './utils.ts'
4-
import { end } from './end.ts'
3+
import { createETag, setCharset } from '../utils.ts'
4+
import { end } from '../end.ts'
55

66
export const send = <Request extends Req = Req, Response extends Res = Res>(req: Request, res: Response) => (
77
body: any

extensions/res/sendFile.ts renamed to extensions/res/send/sendFile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Req, Res } from '../../deps.ts'
1+
import { Req, Res } from '../../../deps.ts'
22
import { isAbsolute, join, extname } from 'https://deno.land/std@0.89.0/path/mod.ts'
3-
import { contentType } from '../../deps.ts'
4-
import { createETag } from './utils.ts'
3+
import { contentType } from '../../../deps.ts'
4+
import { createETag } from '../utils.ts'
55
import { send } from './send.ts'
66

77
export type SendFileOptions = Partial<{

extensions/res/sendStatus.ts renamed to extensions/res/send/sendStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Req, Res } from '../../deps.ts'
1+
import { Req, Res } from '../../../deps.ts'
22
import { send } from './send.ts'
33
import { status } from 'https://deno.land/x/status/status.ts'
44

tests/core/app.method.test.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/core/app.route.test.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)