@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
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,
}),
],
})| Option | Default | Meaning |
|---|---|---|
path | /_inspector | Dashboard path; JSON at <path>/entries?type=query |
limit | 1000 | Entries kept in memory (oldest dropped first) |
gate | none | Access outside local. Without a gate the dashboard is a 404 there, so its presence is not revealed |
recordInProduction | false | Record outside local too (still behind the gate) |
What is recorded
- Requests: method, path, status and duration, read through the
http:responsefilter. - Queries: SQL and duration from the
samveys:db.querytracing channel.@samveys/databasepublishes 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.