From 1d8c3484540f2bf5fa70eed2485df0b03efafa5b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 18 Jun 2017 00:28:24 +0200 Subject: feat: setup basic web server --- src/index.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/index.js') diff --git a/src/index.js b/src/index.js index e69de29..9ba74de 100644 --- a/src/index.js +++ b/src/index.js @@ -0,0 +1,25 @@ +'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() + +router.get('/', function (ctx, next) { + ctx.status = 200 + ctx.body = 'hello world' + next() +}) + +app.use(router.routes()).use(router.allowedMethods()) + +module.exports = app + +if (require.main === module) { + app.listen(PORT, () => { + console.log(`App listening on port ${PORT}`) + }) +} -- cgit 1.4.1