homepage.js/middleware/template.js

20 lines
458 B
JavaScript
Raw Normal View History

2023-03-05 14:56:16 +01:00
const express = require('express');
const router = new express.Router();
const Helpers = require('../helpers');
2023-03-05 15:26:56 +01:00
module.exports = (req, res, next) => {
2023-03-05 14:56:16 +01:00
if (res.template) return next();
2023-03-05 15:26:56 +01:00
2023-03-05 14:56:16 +01:00
res.template = async (file, data) => {
res.send(await Helpers.ViewLoader.load(file, {
...data,
current_route: req.originalUrl,
req,
res,
require
}))
}
2023-03-05 15:26:56 +01:00
return next();
}