Skip to content

Koa

Install Kilpi for Koa

Ensure you have setup Kilpi using the quickstart guide before proceeding.

Installing Kilpi for Koa is as easy as providing Kilpi scope within a middleware. You do not need any plugins. We also recommend to set an onUnauthorized handler to throw an HTTPException with a 403 status code.

app.use(async (ctx, next) => {
Kilpi.runInScope(async () => {
Kilpi.onUnauthorized(({ message }) => {
ctx.throw(403, message);
})
await next();
})
})