Koa minimal example

Also see Minimal Koa.JS example with Router & Body parser

koa-example.js
const Koa = require('koa');
const app = new Koa();

app.use(async ctx => {
  ctx.body = {status: 'success'};
});

app.listen(8080);

To install (see this previous post for a guide on installing NodeJS & NPM):

install-and_run.sh
npm install --save koa
node index.js

Then go to http://localhost:8080/ to see the test page.


Check out similar posts by category: Javascript