@samveys/inspector

Versi
1.0.35 Nov 2026
Pasang
pnpm add @samveys/inspector

Dari packages/inspector/README.md di repository framework.

Halaman ini belum diterjemahkan. Kamu sedang membaca versi bahasa Inggris.

A development inspector: it records requests, database queries, exceptions, and anything other packages report (mail, jobs), and shows them at /_inspector.

Use it

ts
import { createApp } from '@samveys/core'
import { http } from '@samveys/http'
import { inspector } from '@samveys/inspector'

export const app = createApp({
  name: 'billing',
  plugins: [
    http(),
    inspector({
      // Outside `local` the dashboard answers only when the gate returns true; otherwise 404.
      gate: (ctx) => ctx.headers.get('x-admin-token') === process.env.INSPECTOR_TOKEN,
    }),
  ],
})
OptionDefaultMeaning
path/_inspectorDashboard path; JSON at <path>/entries?type=query
limit1000Entries kept in memory (oldest dropped first)
gatenoneAccess outside local. Without a gate the dashboard is a 404 there, so its presence is not revealed
recordInProductionfalseRecord outside local too (still behind the gate)

What is recorded

  • Requests: method, path, status and duration, read through the http:response filter.
  • Queries: SQL and duration from the samveys:db.query tracing channel. @samveys/database publishes it only while someone listens, so it costs nothing otherwise.
  • Exceptions: name, message and SVS_E* code.
  • Custom entries: container.make('inspector').record('mail', { to, subject }).

Keys that look like secrets (password, token, secret, authorization, cookie, api_key) are stored as [redacted].

svs inspector:prune [--hours 24] deletes older entries.