UNPKG

2.12 kBTypeScriptView Raw
1/// <reference types="node" />
2import { Event } from '@sentry/types';
3import * as http from 'http';
4/**
5 * Express compatible tracing handler.
6 * @see Exposed as `Handlers.tracingHandler`
7 */
8export declare function tracingHandler(): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void;
9declare type TransactionTypes = 'path' | 'methodPath' | 'handler';
10/**
11 * Options deciding what parts of the request to use when enhancing an event
12 */
13interface ParseRequestOptions {
14 request?: boolean | string[];
15 serverName?: boolean;
16 transaction?: boolean | TransactionTypes;
17 user?: boolean | string[];
18 version?: boolean;
19}
20/**
21 * Enriches passed event with request data.
22 *
23 * @param event Will be mutated and enriched with req data
24 * @param req Request object
25 * @param options object containing flags to enable functionality
26 * @hidden
27 */
28export declare function parseRequest(event: Event, req: {
29 [key: string]: any;
30}, options?: ParseRequestOptions): Event;
31/**
32 * Express compatible request handler.
33 * @see Exposed as `Handlers.requestHandler`
34 */
35export declare function requestHandler(options?: ParseRequestOptions & {
36 flushTimeout?: number;
37}): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void;
38/** JSDoc */
39interface MiddlewareError extends Error {
40 status?: number | string;
41 statusCode?: number | string;
42 status_code?: number | string;
43 output?: {
44 statusCode?: number | string;
45 };
46}
47/**
48 * Express compatible error handler.
49 * @see Exposed as `Handlers.errorHandler`
50 */
51export declare function errorHandler(options?: {
52 /**
53 * Callback method deciding whether error should be captured and sent to Sentry
54 * @param error Captured middleware error
55 */
56 shouldHandleError?(error: MiddlewareError): boolean;
57}): (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
58/**
59 * @hidden
60 */
61export declare function logAndExitProcess(error: Error): void;
62export {};
63//# sourceMappingURL=handlers.d.ts.map
\No newline at end of file