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

Commit 99ff621

Browse files
author
v1rtl
committed
update server.ts
1 parent 8a1fd9c commit 99ff621

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

egg.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
"description": "0-legacy, tiny & fast web framework as a replacement of Express",
66
"homepage": "https://github.com/talentlessguy/tinyhttp-deno",
77
"version": "0.0.14",
8-
"ignore": ["./examples/**/*.ts"],
9-
"files": ["./**/*.ts", "README.md"],
8+
"ignore": [
9+
"./examples/**/*.ts"
10+
],
11+
"files": [
12+
"./**/*.ts",
13+
"README.md"
14+
],
1015
"checkFormat": false,
1116
"checkTests": false,
1217
"checkInstallation": false,

examples/mongodb/server.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ type Req = Request & {
99
bodyResult: any
1010
}
1111

12-
const app = new App<any, Req>({
13-
onError: (err, req) => {
14-
console.log(err)
15-
req.respond({ body: 'Error' })
16-
}
17-
})
12+
const app = new App<any, Req>()
1813
const port = parseInt(Deno.env.get('PORT') || '') || 3000
1914

2015
// connect to mongodb
@@ -37,7 +32,7 @@ app.get('/notes', async (_, res, next) => {
3732
}
3833
})
3934

40-
const bodyParser: Handler<Req> = async (req, res, next) => {
35+
const bodyParser: Handler<Req> = async (req, _res, next) => {
4136
const buf = await Deno.readAll(req.body)
4237

4338
const dec = new TextDecoder()
@@ -58,7 +53,7 @@ app.use(bodyParser)
5853
app.post('/notes', async (req, res, next) => {
5954
try {
6055
const { title, desc } = req.bodyResult
61-
const r = await coll.insertOne({ title, desc })
56+
await coll.insertOne({ title, desc })
6257

6358
res.send(`Note with title of "${title}" has been added`)
6459
} catch (err) {

0 commit comments

Comments
 (0)