UNPKG

2.26 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 ip?: boolean;
15 request?: boolean | string[];
16 serverName?: boolean;
17 transaction?: boolean | TransactionTypes;
18 user?: boolean | string[];
19 version?: boolean;
20}
21/**
22 * Enriches passed event with request data.
23 *
24 * @param event Will be mutated and enriched with req data
25 * @param req Request object
26 * @param options object containing flags to enable functionality
27 * @hidden
28 */
29export declare function parseRequest(event: Event, req: {
30 [key: string]: any;
31 user?: {
32 [key: string]: any;
33 };
34 ip?: string;
35 connection?: {
36 remoteAddress?: string;
37 };
38}, options?: ParseRequestOptions): Event;
39/**
40 * Express compatible request handler.
41 * @see Exposed as `Handlers.requestHandler`
42 */
43export declare function requestHandler(options?: ParseRequestOptions & {
44 flushTimeout?: number;
45}): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void;
46/** JSDoc */
47interface MiddlewareError extends Error {
48 status?: number | string;
49 statusCode?: number | string;
50 status_code?: number | string;
51 output?: {
52 statusCode?: number | string;
53 };
54}
55/**
56 * Express compatible error handler.
57 * @see Exposed as `Handlers.errorHandler`
58 */
59export declare function errorHandler(options?: {
60 /**
61 * Callback method deciding whether error should be captured and sent to Sentry
62 * @param error Captured middleware error
63 */
64 shouldHandleError?(error: MiddlewareError): boolean;
65}): (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
66/**
67 * @hidden
68 */
69export declare function logAndExitProcess(error: Error): void;
70export {};
71//# sourceMappingURL=handlers.d.ts.map
\No newline at end of file