Monitor an Express or NestJS API in a few lines
Install midline-agent, initialise it with a project key and add one line to your app. You get request logs, grouped errors and your server’s console output in the dashboard, without adding a hop to the request path.
Install
One package covers the server and the browser: midline-agent for the API (midline-agent/nest for NestJS), and midline-agent/browser for the web app. Create a project key under Project, then API Keys in the dashboard.
- npm install midline-agent
Express
Register the middleware before your routes so every request is seen, and the error handler after them. The error handler records the error and passes it on untouched, so your own handling is not changed.
NestJS
Import MidlineModule.forRoot in your AppModule. It starts the agent before Nest boots, records every request, and reports the exceptions Nest handles in its own filters, which never reach Express error middleware. Nest’s responses are unchanged, and queued events are flushed on shutdown once app.enableShutdownHooks() is on. Without the module, app.use(midlineMiddleware()) still records every request, and Midline groups 5xx responses into issues by method, route and status.
Plain Node http
Not on a framework? midlineMiddleware() returns a plain (req, res, next) function you can call from a raw http server.
More than a request logger
A console logger such as morgan writes a line per request to a stream. Midline stores each request as a searchable event, calculates error rate and latency, captures what your server prints to the console, and groups failures into issues.
- Console output is captured with a severity taken from the line: ERROR and FATAL are high, WARN and other stderr output are medium.
- Printed lines never count towards request totals, error rate or latency.
- Credentials are masked in your process before anything is queued.
import { Module } from "@nestjs/common";
import { MidlineModule } from "midline-agent/nest";
@Module({
imports: [
MidlineModule.forRoot({
apiKey: process.env.MIDLINE_API_KEY,
serviceName: "nest-api",
environment: process.env.NODE_ENV,
}),
],
})
export class AppModule {}
Questions
How do I monitor an Express API?
Install midline-agent, call MidlineAgent.init with your project key, register midlineMiddleware() before your routes and midlineErrorHandler() after them. Requests and errors then appear in the Midline dashboard.
Does it work with NestJS?
Yes. Import MidlineModule.forRoot from midline-agent/nest in your AppModule. It records every request and reports the exceptions Nest’s own filters would otherwise swallow, without changing Nest’s responses.
What happens if Midline is unreachable?
Your API is unaffected. Events wait in a bounded buffer and are retried with exponential backoff and jitter, honouring Retry-After. If the API key is rejected, the agent logs once and stops.
Is certificate verification ever disabled?
No. TLS verification is always on and there is no option to turn it off. A self-hosted Midline server behind a private CA can be trusted for the Midline connection only.
Server agent · API keys · Quick start
Start free