This documentation is deprecated. Please refer our new documentation here

Koa.js Integration

Koa is the amazing web framework for Node.js. Even though Atatus Node APM supports major frameworks without any extra code, Koa applications need some extra configurations.

Install koa-atatus package

This package provides a Koa middleware to allow Atatus monitor Koa 2.x applications like Express.

npm install --save atatus-node
npm install --save koa-atatus
Add koa-atatus middleware

You have to add the koa-atatus middleware to every koa router instance before defining the routes.

// Atatus Node Agent
const atatus = require("atatus-node");
atatus.start({
    apiKey: 'YOUR_API_KEY',
});

// TODO: Add this line - Koa Atatus Middleware
const koaAtatus = require('koa-atatus')(atatus);

const Koa = require('koa'),
    Router = require('koa-router');

const app = new Koa();
const router = new Router();
router.use(koaAtatus);  // TODO: Add this line for every router instance.

// Routes
router.get('/', async function (next) {...});

// TODO: Add this line for error capturing.
app.on('error', (err, ctx) => {
    atatus.notifyError(err);
});

app.use(router.routes());
app.listen(3000);
Document Sections