From 77c1b6934f4496c7e7534dd4706b3ed4040c0dcf Mon Sep 17 00:00:00 2001 From: Garv Date: Fri, 31 Jul 2026 23:16:26 +0530 Subject: [PATCH 1/3] chore: add jsr.json manifest for JSR registry publishing --- jsr.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 jsr.json diff --git a/jsr.json b/jsr.json new file mode 100644 index 0000000..b78787d --- /dev/null +++ b/jsr.json @@ -0,0 +1,13 @@ +{ + "name": "@codebygarv/express-lens", + "version": "2.5.0", + "description": "Zero-dependency HTTP monitoring, APM metrics, percentile latencies, Prometheus format exporter, slow request profiler, and real-time web dashboard for Express, Fastify, Hono, and Next.js.", + "license": "MIT", + "exports": { + ".": "./index.ts", + "./express": "./src/adapters/express.ts", + "./fastify": "./src/adapters/fastify.ts", + "./hono": "./src/adapters/hono.ts", + "./next": "./src/next.ts" + } +} From f52c9b6d48994d2b976252780ae73192b8f70bfc Mon Sep 17 00:00:00 2001 From: Garv Date: Fri, 31 Jul 2026 23:17:53 +0530 Subject: [PATCH 2/3] fix: add explicit TypeScript return types for JSR type validation --- src/adapters/fastify.ts | 4 ++-- src/adapters/hono.ts | 4 ++-- src/next.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/adapters/fastify.ts b/src/adapters/fastify.ts index 9182988..76059a8 100644 --- a/src/adapters/fastify.ts +++ b/src/adapters/fastify.ts @@ -6,11 +6,11 @@ import type { ExpressLensOptions } from '../middleware.ts'; /** * Fastify plugin adapter for Express Lens HTTP monitoring and debugging. */ -export function fastifyExpressLens(options: ExpressLensOptions = {}) { +export function fastifyExpressLens(options: ExpressLensOptions = {}): (fastify: any) => Promise { const slowThresholdMs = options.slowThresholdMs != null ? options.slowThresholdMs : 500; const customRedactList = Array.isArray(options.redactHeaders) ? options.redactHeaders : []; - return async function expressLensPlugin(fastify: any) { + return async function expressLensPlugin(fastify: any): Promise { const requestTimes = new WeakMap(); // 1. Hook into onRequest to record start time diff --git a/src/adapters/hono.ts b/src/adapters/hono.ts index 70fb268..6d13cc9 100644 --- a/src/adapters/hono.ts +++ b/src/adapters/hono.ts @@ -7,11 +7,11 @@ import type { ExpressLensOptions } from '../middleware.ts'; * Hono & Edge framework adapter for Express Lens HTTP monitoring and debugging. * Compatible with Hono, Cloudflare Workers, Deno, Bun, and Vercel Edge. */ -export function honoExpressLens(options: ExpressLensOptions = {}) { +export function honoExpressLens(options: ExpressLensOptions = {}): (c: any, next: () => Promise) => Promise { const slowThresholdMs = options.slowThresholdMs != null ? options.slowThresholdMs : 500; const customRedactList = Array.isArray(options.redactHeaders) ? options.redactHeaders : []; - return async function middleware(c: any, next: () => Promise) { + return async function middleware(c: any, next: () => Promise): Promise { const url = c.req.url || c.req.path || '/'; // 1. Intercept /express-lens dashboard endpoints directly inside Hono diff --git a/src/next.ts b/src/next.ts index 411ece2..a004acf 100644 --- a/src/next.ts +++ b/src/next.ts @@ -6,11 +6,11 @@ import type { ExpressLensOptions } from './middleware.ts'; /** * Higher-Order Function to wrap Next.js App Router route handlers with HTTP monitoring. */ -export function withExpressLens(handler: Function, options: ExpressLensOptions = {}) { +export function withExpressLens(handler: Function, options: ExpressLensOptions = {}): (req: Request, context?: any) => Promise { const slowThresholdMs = options.slowThresholdMs != null ? options.slowThresholdMs : 500; const customRedactList = Array.isArray(options.redactHeaders) ? options.redactHeaders : []; - return async function expressLensNextHandler(req: Request, context?: any) { + return async function expressLensNextHandler(req: Request, context?: any): Promise { const startTime = globalThis.performance ? globalThis.performance.now() : Date.now(); const url = req.url || '/'; const method = req.method || 'GET'; @@ -102,8 +102,8 @@ export function withExpressLens(handler: Function, options: ExpressLensOptions = * Route handler for exposing the Express Lens dashboard in Next.js catch-all route. * Usage: export const GET = dashboardRoute(); inside app/api/express-lens/[[...route]]/route.ts */ -export function dashboardRoute() { - return async function handleNextDashboard(req: Request) { +export function dashboardRoute(): (req: Request) => Promise { + return async function handleNextDashboard(req: Request): Promise { const url = req.url || ''; if (url.includes('/metrics-json')) { return Response.json(store.getMetrics()); From f4aa50d2624d8c4a4ee7b614e9d2f3ddbeb0b7d5 Mon Sep 17 00:00:00 2001 From: Garv Date: Fri, 31 Jul 2026 23:18:13 +0530 Subject: [PATCH 3/3] ci: add JSR release workflow --- .github/workflows/jsr-publish.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/jsr-publish.yml diff --git a/.github/workflows/jsr-publish.yml b/.github/workflows/jsr-publish.yml new file mode 100644 index 0000000..4fac8a7 --- /dev/null +++ b/.github/workflows/jsr-publish.yml @@ -0,0 +1,23 @@ +name: Publish to JSR + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Publish package to JSR + run: npx jsr publish