-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.d.ts
65 lines (57 loc) · 1.66 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: strong-error-handler
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
// Type definitions for strong-error-handler 3.x
// Project: https://github.com/strongloop/strong-error-handler
// Definitions by: Kyusung Shim <https://github.com/shimks>
// TypeScript Version: 3.0
import * as Express from 'express';
export = errorHandlerFactory;
/**
* Creates a middleware function for error-handling
* @param options Options for error handler settings
*/
declare function errorHandlerFactory(
options?: errorHandlerFactory.ErrorHandlerOptions
): errorHandlerFactory.StrongErrorHandler;
declare namespace errorHandlerFactory {
/**
* Writes thrown error to response
* @param err Error to handle
* @param req Incoming request
* @param res Response
* @param options Options for error handler settings
*/
function writeErrorToResponse(
err: Error,
req: Express.Request,
res: Express.Response,
options?: ErrorWriterOptions
): void;
/**
* Error-handling middleware function. Includes server-side logging
*/
type StrongErrorHandler = (
err: Error,
req: Express.Request,
res: Express.Response,
next: (err?: any) => void
) => void;
/**
* Options for writing errors to the response
*/
interface ErrorWriterOptions {
debug?: boolean;
safeFields?: string[];
defaultType?: string;
negotiateContentType?: boolean;
rootProperty?: string | false;
}
/**
* Options for error-handling
*/
interface ErrorHandlerOptions extends ErrorWriterOptions {
log?: boolean;
}
}