boilerplate more
This commit is contained in:
parent
bf77320bc7
commit
ae511a3871
8 changed files with 301 additions and 74 deletions
19
index.js
19
index.js
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue