Fri Jan 27 2017
Copied to clipboard! Copy reply
  • 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
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
import 'babel-polyfill'
import os from 'os'
import path from 'path'
import fs from 'fs-extra'
import exec from 'child_process'
import Koa from 'koa'
import cors from 'kcors'
import Router from 'koa-router'
import koaBody from 'koa-body'
import convert from 'koa-convert'
import session from "koa-session2"
import websockify from 'koa-websocket'
import * as route from './routes'
import cfg from './config'
import Store from './memstore'




const app = new Koa();
const router = new Router()

router.get('/', home)

app.use((ctx, next) => {
  console.log('1st middleware. Setting cookie to "blue"')
  ctx.cookies.set('color', 'blue')
  next()
})

app.use(router.routes())

function home(ctx, next) {
  var cookie = ctx.cookies.get('color')
  console.log('Inside /home handler. Cookie: ', cookie)
  // cookie is undefined
}


app.listen(3000);