import * as Koa from "koa";
import * as Router from "koa-router";
import * as json from "koa-json";
import * as bodyParser from "koa-bodyparser";

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

app.use( json() );
app.use( bodyParser() );
app.use( router.routes() ).use( router.allowedMethods() );



router.get( '/', async (ctx: Koa.Context, next: () => Promise<any>) => {

    ctx.body = { message: "Hello world!" };

    await next();
});


app.listen( PORT, () => console.log( "Server started at " + PORT ) );