@@ -92,11 +92,25 @@ export declare type ErrorHandlingMiddleware<
92
92
> ,
93
93
TBody = any
94
94
> = (
95
+ /**
96
+ * The error that was thrown or passed to res.error()
97
+ */
95
98
error : Error ,
99
+ /**
100
+ * The request object
101
+ */
96
102
req : Request < TContext , TQuery , TParams , TBody > ,
103
+ /**
104
+ * The response object. Call res.send() or return a value to send a response.
105
+ * The error will continue through the error middleware chain until a response is sent.
106
+ */
97
107
res : Response < TResponse > ,
108
+ /**
109
+ * Call next() to continue to the next error middleware.
110
+ * Note: next(error) is not supported - the error parameter will be ignored.
111
+ */
98
112
next : NextFunction
99
- ) => void ;
113
+ ) => void | Promise < void | TResponse > | TResponse ;
100
114
101
115
export type METHODS =
102
116
| 'GET'
@@ -142,23 +156,32 @@ export declare interface LoggerOptions {
142
156
customKey ?: string ;
143
157
errorLogging ?: boolean ;
144
158
detail ?: boolean ;
145
- level ?: string ;
159
+ level ?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' | 'none' ;
146
160
levels ?: {
147
- [ key : string ] : string ;
161
+ [ key : string ] : number ;
148
162
} ;
149
163
messageKey ?: string ;
150
164
nested ?: boolean ;
151
165
timestamp ?: boolean | TimestampFunction ;
152
- sampling ?: {
153
- target ?: number ;
154
- rate ?: number ;
155
- period ?: number ;
156
- rules ?: SamplingOptions [ ] ;
157
- } ;
166
+ sampling ?:
167
+ | boolean
168
+ | {
169
+ target ?: number ;
170
+ rate ?: number ;
171
+ period ?: number ;
172
+ rules ?: SamplingOptions [ ] ;
173
+ } ;
158
174
serializers ?: {
159
- [ name : string ] : ( prop : any ) => any ;
175
+ main ?: ( req : Request ) => object ;
176
+ req ?: ( req : Request ) => object ;
177
+ res ?: ( res : Response ) => object ;
178
+ context ?: ( context : Context ) => object ;
179
+ custom ?: ( custom : any ) => object ;
160
180
} ;
161
181
stack ?: boolean ;
182
+ timer ?: boolean ;
183
+ multiValue ?: boolean ;
184
+ log ?: ( message : string ) => void ;
162
185
}
163
186
164
187
export interface Options {
@@ -214,7 +237,7 @@ export declare class Request<
214
237
} ;
215
238
body : TBody ;
216
239
rawBody : string ;
217
- route : '' ;
240
+ route : string ;
218
241
requestContext : TContext ;
219
242
isBase64Encoded : boolean ;
220
243
pathParameters : { [ name : string ] : string } | null ;
@@ -235,6 +258,12 @@ export declare class Request<
235
258
clientType : 'desktop' | 'mobile' | 'tv' | 'tablet' | 'unknown' ;
236
259
clientCountry : string ;
237
260
namespace : App ;
261
+ /**
262
+ * Alias for namespace
263
+ */
264
+ ns : App ;
265
+ interface : 'apigateway' | 'alb' ;
266
+ payloadVersion ?: string ;
238
267
239
268
log : {
240
269
trace : LoggerFunction ;
@@ -249,6 +278,8 @@ export declare class Request<
249
278
}
250
279
251
280
export declare class Response < TResponse = any > {
281
+ app : API ;
282
+
252
283
status ( code : number ) : this;
253
284
sendStatus ( code : number ) : void ;
254
285
header ( key : string , value ?: string | Array < string > , append ?: boolean ) : this;
0 commit comments