const aliases = { '/': '/walls/get/home' }; function doAliases(app) { for (let alias in aliases) { app.all(alias, (req,res,next) => { res.redirect(aliases[alias]) }) } } function doInit(app) { app.use((req, res, next) => { res.ctx = { mainPage: '404.ejs', mainCtx: {}, headerCtx: [ { link: '/walls/get/home', icon: '/icon.svg', name: 'DervNet' }, { link: '/walls/list', icon: '/walls.svg', name: 'Explore' }, { link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon ] }; next(); }) doAliases(app); app.use('/api', (req, res, next) => { res.send(res.ctx); }) app.use((req, res, next) => { res.render('root.ejs', res.ctx) }) } export { doInit };