IDebug is experimental. Prefer enabling only in development.
Packages@idebug/node

@idebug/node (Express)

Records request/response, middleware, and function I/O; serves the debug UI at /__idebug.

Install

pnpm add @idebug/node express
pnpm --filter @idebug/ui build   # monorepo: ensure SPA dist exists

Full example

import express from 'express';
import IDebug, {
  configure,
  middleware,
  ui,
  logModule,
  logFunction,
} from '@idebug/node';
 
configure({
  enabled: process.env.NODE_ENV !== 'production',
  performance: true,
  appName: 'my-api',
  db: true, // default when enabled; wrap clients with instrumentPrisma / instrumentKnex / …
});
 
const app = express();
app.use(express.json());
app.use(middleware());
 
const calc = logModule(
  {
    add: (a: number, b: number) => a + b,
    divide: (a: number, b: number) => {
      if (b === 0) throw new Error('Division by zero is not allowed');
      return a / b;
    },
  },
  'calc',
);
 
const stamp = logFunction(function stamp(n: number) {
  return { n, at: Date.now() };
});
 
app.get('/add', (req, res) => {
  res.json({ sum: calc.add(Number(req.query.a), Number(req.query.b)) });
});
 
app.use(ui());
// or: IDebug.attach(app) for middleware + ui after you add parsers yourself
 
app.listen(3000);
// → http://localhost:3000/__idebug

Middleware order

  1. Body parsers (express.json(), cookies, …) so req snapshots include bodies.
  2. middleware() — starts session, ALS, req / res / mutations / errors.
  3. Application routes.
  4. ui() — path-gated under basePath; register anytime after parsers.

Do not mount Express as app.use('/__idebug', ui()) in a way that strips the prefix unless you also set basePath accordingly. Preferred: full-path matching via ui() as documented in the package README.

Public API

APIDescription
configure(partial)Merge config (enabled default false)
middleware()ALS + tracing
ui()Mounts createIdebugHandler
attach(app)middleware + ui
logFunction(fn)enter + exit functionCall events
logModule(mod, name)Wrap all functions on an object
trackMiddlewares(app)Emit middlewareCall for app.use
getStore()Default core store
instrumentPrisma etc.Re-exports from @idebug/db

Database call-tree demo: sample-db-api on port 3003 (samples/db-api). See Database queries. | IDebug / default export | Same facade |

Mutation sources

res.setHeader / res.status while inside Express res.json / res.send are tagged source: 'framework'. App code is tagged source: 'app'. The UI App changes only toggle hides framework noise (e.g. Content-Type).

Disabled behavior

When enabled: false:

  • Middleware calls next() immediately.
  • logFunction / logModule still invoke the original functions (no recording).