UNPKG

2.42 kBTypeScriptView Raw
1/// <reference types="node" />
2import type { AddRequestDataToEventOptions } from '@sentry/utils';
3import type * as http from 'http';
4import type { ParseRequestOptions } from './requestDataDeprecated';
5/**
6 * Express-compatible tracing handler.
7 * @see Exposed as `Handlers.tracingHandler`
8 */
9export declare function tracingHandler(): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void;
10export declare type RequestHandlerOptions = (ParseRequestOptions | AddRequestDataToEventOptions) & {
11 flushTimeout?: number;
12};
13/**
14 * Express compatible request handler.
15 * @see Exposed as `Handlers.requestHandler`
16 */
17export declare function requestHandler(options?: RequestHandlerOptions): (req: http.IncomingMessage, res: http.ServerResponse, next: (error?: any) => void) => void;
18/** JSDoc */
19interface MiddlewareError extends Error {
20 status?: number | string;
21 statusCode?: number | string;
22 status_code?: number | string;
23 output?: {
24 statusCode?: number | string;
25 };
26}
27/**
28 * Express compatible error handler.
29 * @see Exposed as `Handlers.errorHandler`
30 */
31export declare function errorHandler(options?: {
32 /**
33 * Callback method deciding whether error should be captured and sent to Sentry
34 * @param error Captured middleware error
35 */
36 shouldHandleError?(this: void, error: MiddlewareError): boolean;
37}): (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
38interface SentryTrpcMiddlewareOptions {
39 /** Whether to include procedure inputs in reported events. Defaults to `false`. */
40 attachRpcInput?: boolean;
41}
42interface TrpcMiddlewareArguments<T> {
43 path: string;
44 type: 'query' | 'mutation' | 'subscription';
45 next: () => T;
46 rawInput: unknown;
47}
48/**
49 * Sentry tRPC middleware that names the handling transaction after the called procedure.
50 *
51 * Use the Sentry tRPC middleware in combination with the Sentry server integration,
52 * e.g. Express Request Handlers or Next.js SDK.
53 */
54export declare function trpcMiddleware(options?: SentryTrpcMiddlewareOptions): Promise<(<T>({ path, type, next, rawInput }: TrpcMiddlewareArguments<T>) => T)>;
55export type { ParseRequestOptions, ExpressRequest } from './requestDataDeprecated';
56export { parseRequest, extractRequestData } from './requestDataDeprecated';
57//# sourceMappingURL=handlers.d.ts.map
\No newline at end of file