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

Commit 6c42cc5

Browse files
author
v1rtl
committed
add res.app
1 parent 4d8c133 commit 6c42cc5

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ app.use('/', (req, res, next) => {
2323

2424
next()
2525
})
26-
2726
app.get('/:name/', (req, res) => {
28-
res.send(`Hello on ${req.url} from Deno and tinyhttp! 🦕`)
27+
res.send(`Hello on ${req.url} from Deno v${Deno.version.deno} and tinyhttp! 🦕`)
2928
})
3029

3130
app.listen(3000, () => console.log(`Started on :3000`))

egg.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
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.7",
8-
"ignore": [
9-
"./examples/**/*.ts"
10-
],
11-
"files": [
12-
"./**/*.ts",
13-
"README.md"
14-
],
7+
"version": "0.0.8",
8+
"ignore": ["./examples/**/*.ts"],
9+
"files": ["./**/*.ts", "README.md"],
1510
"checkFormat": false,
1611
"checkTests": false,
1712
"checkInstallation": false,

examples/basic/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { App } from '../../app.ts'
22

33
const app = new App()
44

5-
app.get('/', (_, res) => void res.send('Hello World'))
5+
app.get('/:name/', (req, res) => {
6+
res.send(`Hello on ${req.url} from Deno v${Deno.version.deno} and tinyhttp! 🦕`)
7+
})
68

79
app.listen(3000, () => console.log(`Started on :3000`))

extend.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const extendMiddleware = <
3838
// Request extensions
3939
if (settings?.bindAppToReqRes) {
4040
req.app = app
41+
res.app = app
4142
}
4243

4344
req.get = getRequestHeader(req)

response.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const renderTemplate = <O = any, Res extends Response = Response>(res: Re
2525

2626
export interface Response<O = any> extends ServerResponse {
2727
headers: Headers
28+
app: App
2829
send(body: unknown): Response
2930
sendFile(path: string, options?: SendFileOptions, cb?: (err?: any) => void): Response
3031
end(body: unknown): Response

0 commit comments

Comments
 (0)