Sitelet https://github.com/GroophyLifefor/express-trace-cli
Skip to content

Repository files navigation

express-trace-cli

Terminal collector for express-emits. Start the CLI, attach the reporter in your app, and watch requests trace live in an interactive three-pane view: sessions (one per attachTraceReporter() call), that session's requests, and the selected request's middleware timeline, logs, and status.

npm install express-trace-cli
npx express-trace-cli --port 4319 --secret devsecret
import express from 'express';
import { expressEmits } from 'express-emits';
import { attachTraceReporter } from 'express-trace-cli';

const app = express();
const { on } = expressEmits(app);
attachTraceReporter(on, { secret: 'devsecret' }); // ships events to the CLI above

app.listen(3000);

In a real terminal you get the interactive view: sessions on the left, that session's requests in the middle, the selected request's middleware timeline and logs on the right.

Key Action
tab cycle focus between panes
1 / 2 / 3 jump to a pane directly
↑/↓ or j/k move the selection in the focused pane
q / ctrl+c quit

Keyboard only, no mouse support (the underlying TUI library doesn't have any).

Piped output, CI, or anything else without a real TTY falls back to a plain scrolling line per finished request instead:

→ GET /users/1  [3]
  ├─ auth                 2.1ms
  └─ anonymous 1          5.8ms
  log [auth] checking token
← 200 in 9.7ms

API

attachTraceReporter(on, options?)

Subscribes to an expressEmits() instance's on and batches its events to the collector over HTTP.

Option Default
url http://localhost:4319/events Collector endpoint.
flushMs 200 Batch flush interval.
secret none Sent as x-trace-secret. Must match the collector's --secret.

Fire and forget: if the collector isn't running, events are dropped silently rather than blocking or retrying. This is a dev-time tool, not a durable log pipeline.

CLI

express-trace-cli [--port <n>] [--secret <token>]
# also: -p/-s shorthand, or PORT/TRACE_SECRET env vars

No --secret means the collector accepts unauthenticated events, fine on a machine you trust, not on a shared or non-localhost host. Setting it rejects any POST whose x-trace-secret header doesn't match, with a 401.

Scope

This covers exactly what express-emits emits: request.start/end, middleware.start/end, and log, grouped into sessions by attachTraceReporter() call. No schema validation, no request/response body capture. express-emits doesn't produce that data.

Development

npm run build
npm run dev

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages