Skip to content

Commit

Permalink
🐛 Remove @types/jest dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Feb 27, 2024
1 parent 5bd534b commit efcd0d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
"functional-programming",
"router"
],
"dependencies": {
"@types/jest": "^27.4.0"
},
"dependencies": {},
"devDependencies": {
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@frenchpastries/millefeuille": "^1.0.2",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.18",
"@types/node-fetch": "^2.6.1",
"eslint": "^8.9.0",
Expand Down
13 changes: 10 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@ export class Router<Input, Output> extends Function {
if (!isAny && !isExprtAny && !isSameMethod) return []
const finalPath = `${path}${exprt.path}`
const path_ = helpers.request.route.removeTrailingSlash(finalPath)
const handler = middlewares.reduce((acc, m) => m(acc), exprt.handler)
const handler: Handler = value => {
const h = middlewares.reduce((acc, m) => m(acc), exprt.handler)
return h(value)
}
Object.defineProperty(handler, 'name', {
value: exprt.handler.name,
writable: false,
})
return [{ method: exprt.method, path: path_, handler }]
})
})
Expand All @@ -123,9 +130,9 @@ export class Router<Input, Output> extends Function {
routes = () => {
const paths = this.export()
return paths.reduce((acc, val) => {
const { method, path } = val
const { method, path, handler } = val
const paths_ = acc[method] ?? []
return { ...acc, [method]: [...paths_, path] }
return { ...acc, [method]: { ...paths_, [path]: handler.name } }
}, {} as Paths)
}

Expand Down

0 comments on commit efcd0d1

Please sign in to comment.