@sentry/node
Version:
Sentry Node SDK using OpenTelemetry for performance instrumentation
41 lines • 1.54 kB
TypeScript
/// <reference types="node" />
import type * as http from 'node:http';
export declare const instrumentExpress: ((options?: unknown) => void) & {
id: string;
};
/**
* Express integration
*
* Capture tracing data for express.
* In order to capture exceptions, you have to call `setupExpressErrorHandler(app)` before any other middleware and after all controllers.
*/
export declare const expressIntegration: () => import("@sentry/types").Integration;
interface MiddlewareError extends Error {
status?: number | string;
statusCode?: number | string;
status_code?: number | string;
output?: {
statusCode?: number | string;
};
}
type ExpressMiddleware = (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
interface ExpressHandlerOptions {
/**
* Callback method deciding whether error should be captured and sent to Sentry
* @param error Captured middleware error
*/
shouldHandleError?(this: void, error: MiddlewareError): boolean;
}
/**
* An Express-compatible error handler.
*/
export declare function expressErrorHandler(options?: ExpressHandlerOptions): ExpressMiddleware;
/**
* Setup an error handler for Express.
* The error handler must be before any other middleware and after all controllers.
*/
export declare function setupExpressErrorHandler(app: {
use: (middleware: ExpressMiddleware) => unknown;
}, options?: ExpressHandlerOptions): void;
export {};
//# sourceMappingURL=express.d.ts.map