Treblle for Koa
To integrate Treblle with Koa, we provide an official SDK for Koa - treblle-koa
.
Installation
npm i @treblle/koa --save
Setting up credentials
@treblle/koa
expects your Treblle API key and project ID to be set as environment varibles in a .env
file or in your production environment.
Below are the environment variable that will be checked by @treblle/koa
TREBLLE_API_KEY
TREBLLE_PROJECT_ID
Setup middleware
@treblle/express
expose a treblle
function which returns a middlware, you can pass this function to app.use()
to register it a middleware.
const Koa = require('koa')
const treblle = require('@treblle/koa')
const app = new Koa()
app.use(treblle())
Treblle will now now start monitoring requests on your Koa server.
Config options
You can optionally pass a config option to the treblle
function.
const Koa = require('koa')
const treblle = require('@treblle/koa')
const app = new Koa()
app.use(
treblle({
apiKey: process.env.TREBLLE_API_KEY,
projectId: process.env.TREBLLE_PROJECT_ID,
additionalFieldsToMask: [],
})
)
The additionalFieldsToMask config option takes in an array of strings that matches properties in your response payload or header that you want to mask