aboutsummaryrefslogtreecommitdiffstats
path: root/app/middlewares/index.ts
blob: 81431ca231c8202bf4ce33b14b9b5ea93f012113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
    
    if (!page) {
        next();
        return;
    }

    res.locals.page = page;
    next();
});