UNPKG

1.54 kBTypeScriptView Raw
1/// <reference types="node" />
2import type * as http from 'node:http';
3export declare const instrumentExpress: ((options?: unknown) => void) & {
4 id: string;
5};
6/**
7 * Express integration
8 *
9 * Capture tracing data for express.
10 * In order to capture exceptions, you have to call `setupExpressErrorHandler(app)` before any other middleware and after all controllers.
11 */
12export declare const expressIntegration: () => import("@sentry/types").Integration;
13interface MiddlewareError extends Error {
14 status?: number | string;
15 statusCode?: number | string;
16 status_code?: number | string;
17 output?: {
18 statusCode?: number | string;
19 };
20}
21type ExpressMiddleware = (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
22interface ExpressHandlerOptions {
23 /**
24 * Callback method deciding whether error should be captured and sent to Sentry
25 * @param error Captured middleware error
26 */
27 shouldHandleError?(this: void, error: MiddlewareError): boolean;
28}
29/**
30 * An Express-compatible error handler.
31 */
32export declare function expressErrorHandler(options?: ExpressHandlerOptions): ExpressMiddleware;
33/**
34 * Setup an error handler for Express.
35 * The error handler must be before any other middleware and after all controllers.
36 */
37export declare function setupExpressErrorHandler(app: {
38 use: (middleware: ExpressMiddleware) => unknown;
39}, options?: ExpressHandlerOptions): void;
40export {};
41//# sourceMappingURL=express.d.ts.map
\No newline at end of file