npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lensjs/adonis

v1.3.4

Published

AdonisJs adapter for lens package

Readme

@lensjs/adonis

AdonisJS adapter for Lens. This package provides a service provider and middleware to seamlessly integrate the Lens monitoring and debugging tool into your AdonisJS applications. It enables automatic logging of requests, database queries, and cache events within the AdonisJS ecosystem.

Features

  • LensServiceProvider: Registers the Lens configuration and initializes the Lens core with AdonisJS-specific adapters and watchers during the application boot process.
  • AdonisAdapter class: Extends LensAdapter from @lensjs/core, providing AdonisJS-specific implementations for handling HTTP requests, database queries (via Adonis's db:query event), cache events, route registration, and serving the Lens UI.
  • defineConfig function: A helper to define the Lens configuration within config/lens.ts, ensuring type safety and proper resolution.
  • LensMiddleware: An AdonisJS middleware that generates a unique requestId for each incoming HTTP request, allowing all subsequent events (queries, cache) within that request's lifecycle to be correlated.
  • Request Watching: Captures detailed information about HTTP requests, including method, URL, headers, body, status code, duration, and associated user (if configured).
  • Query Watching: Hooks into AdonisJS's database query events to log SQL queries, their bindings, duration, and type.
  • Cache Watching: Listens to AdonisJS cache events (read, write, hit, miss, delete, clear) to log cache interactions.
  • Exception Watching: Captures and logs exceptions and errors within your AdonisJS application.
  • UI Serving: Serves the Lens UI within your AdonisJS application at a configurable path.
  • Configurable Watchers: Allows enabling or disabling specific watchers (requests, queries, cache) via the Lens configuration.
  • Authentication/User Context: Supports optional isAuthenticated and getUser functions in the configuration to associate request logs with authenticated users.
  • Console/Command Ignoring: Provides utilities to ignore logging for console commands or specific environments.

Installation

pnpm add @lensjs/adonis
node ace configure @lensjs/adonis

(The node ace configure command will typically set up the service provider and config file.)

Usage Example (config/lens.ts)

import { defineConfig } from '@lensjs/adonis';

export default defineConfig({
  appName: 'My Adonis App',
  enabled: true, // Set to false in production
  path: '/lens', // Access Lens UI at /lens
  ignoredPaths: [], // Regex patterns for paths to ignore
  onlyPaths: [],   // Regex patterns for paths to only watch
  watchers: {
    queries: {
      enabled: true,
      provider: 'sqlite', // or 'postgresql', 'mysql', 'mariadb', 'plsql', 'transactsql'
    },
    cache: true,
    requests: true,
    exceptions: true,
  },
  // Optional: Integrate with your authentication system
  isAuthenticated: async (ctx) => {
    return !!ctx.auth.user;
  },
  getUser: async (ctx) => {
    return { id: ctx.auth.user!.id, name: ctx.auth.user!.email };
  },
});

Usage Example (start/kernel.ts - Register Middleware)

// ... other imports
import LensMiddleware from '@lensjs/adonis/lens_middleware';

Server.middleware.global([
  // ... other global middleware
  () => new LensMiddleware(), // Register Lens middleware
]);