Add AWS Lambda Handler function type definition (#13980)

This commit is contained in:
Toby Hede
2017-01-18 17:31:00 +11:00
committed by Mohamed Hegazy
parent 8cc15342ab
commit 1621a99587
2 changed files with 18 additions and 5 deletions

View File

@@ -62,4 +62,7 @@ context.succeed(str);
context.succeed(anyObj);
context.succeed(str, anyObj);
context.fail(error);
context.fail(str);
context.fail(str);
/* Handler */
let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => {};

18
aws-lambda/index.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for AWS Lambda
// Project: http://docs.aws.amazon.com/lambda
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Context
@@ -17,7 +17,7 @@ interface Context {
logStreamName: string;
identity?: CognitoIdentity;
clientContext?: ClientContext;
// Functions
getRemainingTimeInMillis(): number;
@@ -28,7 +28,7 @@ interface Context {
fail(message: string): void;
succeed(message: string): void;
succeed(object: any): void;
succeed(message: string, object: any): void;
succeed(message: string, object: any): void;
}
interface CognitoIdentity {
@@ -58,6 +58,16 @@ interface ClientContextEnv {
locale: string;
}
/**
* AWS Lambda handler function.
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
*
* @param event event data.
* @param context runtime information of the Lambda function that is executing.
* @param callback optional callback to return information to the caller, otherwise return value is null.
*/
export type Handler = (event: any, context: Context, callback?: Callback) => void;
/**
* Optional callback parameter.
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
@@ -67,4 +77,4 @@ interface ClientContextEnv {
*/
export type Callback = (error?: Error, result?: any) => void;
export as namespace AWSLambda;
export as namespace AWSLambda;