boilerplate
This commit is contained in:
commit
bf77320bc7
10 changed files with 3638 additions and 0 deletions
28
index.js
Normal file
28
index.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import express from "express";
|
||||
|
||||
const app = express()
|
||||
const port = 3000;
|
||||
|
||||
app.use(express.static('public'));
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
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)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue