src/index.js (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 'use strict' const PORT = process.env.PORT || 3000 const Koa = require('koa') const app = new Koa() const Router = require('koa-router') const router = new Router() const view = require('koa-nunjucks-next') app.use(view(`${__dirname}/views`)) router.get('/', async function (ctx, next) { await ctx.render('index') }) app.use(router.routes()).use(router.allowedMethods()) module.exports = app if (require.main === module) { app.listen(PORT, () => { console.log(`App listening on port ${PORT}`) }) } |