boilerplate more

This commit is contained in:
biglyderv 2025-02-25 16:02:31 -05:00
parent bf77320bc7
commit ae511a3871
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
8 changed files with 301 additions and 74 deletions

View file

@ -1,28 +1,15 @@
import express from "express";
import { doInit } from "./init.js";
const app = express()
const port = 3000;
app.use(express.static('public'));
app.set('view engine', 'ejs');
app.enable('view cache');
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
app.use((req, res, next) => {
res.ctx = {
mainPage: '404.ejs',
mainCtx: {},
headerCtx: {}
};
next();
})
app.use('/api', (req, res, next) => {
res.send(res.ctx);
})
app.use((req, res, next) => {
res.render('root.ejs', res.ctx)
})
doInit(app);