forked from middyjs/middy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
41 lines (32 loc) · 1.05 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
import { Callback, Context, Handler, ProxyResult } from 'aws-lambda';
type AsyncHandler = (event: any, context: Context) => Promise<ProxyResult | object>;
declare var middy: {
(handler: Handler | AsyncHandler): middy.IMiddy;
};
declare namespace middy {
interface IMiddy extends Handler {
use: IMiddyUseFunction;
before: (callbackFn: IMiddyMiddlewareFunction) => IMiddy;
after: (callbackFn: IMiddyMiddlewareFunction) => IMiddy;
onError: (callbackFn: IMiddyMiddlewareFunction) => IMiddy;
}
type IMiddyUseFunction = (config?: object) => IMiddy;
interface IMiddyMiddlewareObject {
before?: IMiddyMiddlewareFunction;
after?: IMiddyMiddlewareFunction;
onError?: IMiddyMiddlewareFunction;
}
type IMiddyMiddlewareFunction = (
handler: IHandlerLambda,
next: IMiddyNextFunction
) => void | Promise<any>;
type IMiddyNextFunction = (error?: any) => void;
interface IHandlerLambda<T = any, V = object> {
event: T;
context: Context;
response: V;
error: Error;
callback: Callback;
}
}
export = middy;