Skip to content

Commit

Permalink
RouteHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
gegehprast committed Aug 29, 2022
1 parent e0bc269 commit e96575f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/http/Types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import express from 'express'

export type RouteHandler = (router: express.Router) => void
3 changes: 2 additions & 1 deletion src/http/router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'fs'
import path from 'path'
import express from 'express'
import { RouteHandler } from './Types'

const ROUTER = express.Router()
const ROUTE_PATH = './routes'
Expand All @@ -12,7 +13,7 @@ const routes = async () => {
.filter((file) => file.endsWith('.js') || file.endsWith('.ts'))

for (const file of files) {
;(await import(`${ROUTE_PATH}/${file}`)).default(ROUTER)
;((await import(`${ROUTE_PATH}/${file}`)).default as RouteHandler)(ROUTER)
}

return ROUTER
Expand Down

0 comments on commit e96575f

Please sign in to comment.