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

node-lens

v0.0.5

Published

Lens is a lightweight developer tool for Node.js apps that lets you log, view, and debug requests and other activity in real time — inspired by Laravel Telescope.

Downloads

1

Readme

🔭 Lens

Lens is a powerful, self-hosted inspection tool for nodejs applications. It provides automatic insights into your requests, database queries, and more, helping you debug and develop faster with a clean, intuitive UI.

Features

  • Automatic Request & Response Logging: Captures detailed information about incoming requests and outgoing responses in your app, including headers, body, and status codes.
  • Database Query Inspection: Log and view SQL queries made during a request's lifecycle.
  • Interactive UI: A modern and clean web interface built with SvelteKit to browse and analyze captured data.
  • Zero-Configuration Setup: Get started quickly with minimal setup. Data is stored locally in a SQLite database.
  • Context-Aware Logging: Automatically associates custom logs (like queries) with the corresponding request that triggered them using AsyncLocalStorage.

Installation

# npm
npm install node-lens

# yarn
yarn add node-lens

# bun
bun add node-lens

Usage

Express Middleware

To get started, simply add the Lens middleware to your Express application.

import express from 'express';
import { lens } from 'node-lens';

const app = express();

// Add the lens middleware.
// This will serve the UI at /lens by default.
app.use(lens());

// Your other routes and middleware...
app.get('/', (req, res) => {
    res.send('Hello World!');
});

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

Once your server is running, navigate to http://localhost:3000/lens to view the UI.

Logging Custom Entries

You can log custom data, such as database queries, using the provided logQuery function. Lens will automatically associate the query with the currently active request.

import { logQuery } from 'node-lens';

// Example within a database service or request handler
async function getUser(id: string) {
    const query = `SELECT * FROM users WHERE id = '${id}'`;

    // Log the query to Lens
    await logQuery(query);

    // ... execute query and return result
}

API Reference

lens(options?: { path?: string }): Router

Creates the Express middleware and returns an Express Router.

  • options.path: The path to mount the Lens UI on. Defaults to /lens.

init(): Promise<void>

Initializes the database schema. This is called automatically by the middleware on the first request, but you can call it manually if you're using the core functions without the Express middleware.

logQuery(query: string): Promise<void>

A helper function to log a SQL query string. Automatically associates the query with the current request.

addEntry(entry: { content: Object; type: string; requestId?: string }): Promise<void>

Adds a generic entry to the log. logQuery is a specialized version of this.

getEntries(): Promise<Entry[]>

Retrieves all log entries from the database.

clearEntries(): Promise<void>

Clears all log entries from the database.