Skip to content

Instantly share code, notes, and snippets.

@NickHeiner
Last active August 29, 2015 14:19
Show Gist options
  • Save NickHeiner/100d9e7b9f887b7f566b to your computer and use it in GitHub Desktop.
Save NickHeiner/100d9e7b9f887b7f566b to your computer and use it in GitHub Desktop.
// heartbeat.js
module.exports = function* heartbeat(next) {
if (this.path !== '/heartbeat') {
return yield next;
}
this.body = 'OK';
}
// in the index.js, we use the middleware
const app = koa();
// ...
app.use(heartbeat);
// ... more middleware, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment