diff options
Diffstat (limited to 'app/middlewares/index.ts')
| -rw-r--r-- | app/middlewares/index.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/app/middlewares/index.ts b/app/middlewares/index.ts index 81431ca..b5fcd34 100644 --- a/app/middlewares/index.ts +++ b/app/middlewares/index.ts @@ -1,16 +1,18 @@ import { PageDirectory } from "../pages.js"; -export const page = ((req, res, next) => { - const path = req.originalUrl == "/" ? 'index' : req.originalUrl.substring(1); - res.locals.path = path; - - const page = PageDirectory.get(path); +export const directory = (pageDirectory: PageDirectory) => { + return ((req, res, next) => { + const path = req.originalUrl == "/" ? 'index' : req.originalUrl.substring(1); + res.locals.path = path; + + const page = pageDirectory.get(path); + + if (!page) { + next(); + return; + } - if (!page) { + res.locals.page = page; next(); - return; - } - - res.locals.page = page; - next(); -}); + }); +} |
