Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2018 06:31
Show Gist options
  • Save anonymous/89f49a2e6791cbf2583dd9f3be57357b to your computer and use it in GitHub Desktop.
Save anonymous/89f49a2e6791cbf2583dd9f3be57357b to your computer and use it in GitHub Desktop.

Tree

-- src
| -- app.ts
| -- server.ts
-- package.json

app.ts

import Koa from 'koa';
import Router from 'koa-router';

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

router.get('/', (ctx: Koa.Context) => {
    ctx.body = 'Hello World';
});

app.use(router.routes());

export = app;

server.ts

import app from './app';

const port = process.env.PORT || 3000;
const server = app.listen(port);
console.info(`Listening to http://localhost:${port} 🚀`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment