summary refs log tree commit diff stats
path: root/src/index.js
blob: 9ba74deab9649d36addd400db86b038ecd631598 (plain)
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
'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}`)
  })
}