Treblle with AdonisJS
Legacy Notice: The dedicated AdonisJS integration is in maintenance mode. We recommend using our unified JavaScript SDK (
treblle-node) instead, which provides better support and more frequent updates. Support for this integration will end on December 31, 2025. To migrate, follow the updated setup guide below.
Recommended: Using the Unified SDK
Section titled “Recommended: Using the Unified SDK”We now recommend using our unified JavaScript SDK which works with AdonisJS:
npm install treblle@^2.0.0Initialize in your AdonisJS application using Koa support (since Adonis runs on Koa):
import { koaTreblle } from "treblle";
Server.middleware.register([ () => ({ handle: koaTreblle({ sdkToken: process.env.TREBLLE_SDK_TOKEN, apiKey: process.env.TREBLLE_API_KEY, }), }),]);Legacy Integration (Deprecated)
Section titled “Legacy Integration (Deprecated)”The original AdonisJS-specific integration is still available but no longer actively maintained.
Legacy Installation
Section titled “Legacy Installation”If you’re still using the legacy integration:
npm i @treblle/adonisjs --saveAfter installation, run the configuration command:
node ace configure @treblle/adonisjsThis will create the treblle-adonisjs config in config/treblle.ts.
Legacy Credentials
Section titled “Legacy Credentials”treblle-adonisjs requires the following environment variables:
TREBLLE_API_KEYTREBLLE_PROJECT_ID
Validate them in your env.ts file:
TREBLLE_API_KEY: Env.schema.string(),TREBLLE_PROJECT_ID: Env.schema.string(),Legacy Setup
Section titled “Legacy Setup”Add the middleware globally in your start/kernel.ts:
Server.middleware.register([() => import('@treblle/adonisjs')])Or use it as a named middleware for specific routes:
Server.middleware.registerNamed({ treblle: () => import('@treblle/adonisjs'),})Then apply to routes:
Route.group(() => { Route.post('/posts', async ({ request }) => { return { success: true, message: 'Post created successfully', data: request.body(), } })}) .prefix('/api/v1') .middleware('treblle')Migration Guide
Section titled “Migration Guide”To migrate from the legacy integration to the unified SDK:
-
Install the new package:
Terminal window npm install treblle@^2.0.0npm uninstall @treblle/adonisjs -
Update your environment variables from
TREBLLE_API_KEY/TREBLLE_PROJECT_IDtoTREBLLE_SDK_TOKEN/TREBLLE_API_KEY -
Update your middleware registration in
start/kernel.tsto use the Koa middleware from the unified SDK -
Test your API endpoints to ensure requests are being captured
For questions during migration, contact support at support@treblle.com