Chapter 6: code samples

This commit is contained in:
Beth Griggs
2020-05-30 19:33:25 +01:00
parent 4f825bdac3
commit b43bf2c378
398 changed files with 6049 additions and 53643 deletions
+25
View File
@@ -0,0 +1,25 @@
const path = require("path");
const Koa = require("koa");
const serve = require("koa-static");
const router = require("@koa/router")();
const views = require('koa-views')
const index = require("./routes/index");
const PORT = process.env.PORT || 3000;
const app = new Koa();
app.use(views(path.join(__dirname, 'views'), {
extension: 'ejs'
}))
app.use(serve(path.join(__dirname, "public")));
router.use("/", index.routes());
app.use(router.routes());
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});