Merge pull request #15451 from moskalyk/master

@types/aws-lambda-mock-context
This commit is contained in:
Nathan Shively-Sanders
2017-03-28 14:53:35 -07:00
committed by GitHub
4 changed files with 81 additions and 0 deletions
@@ -0,0 +1,22 @@
import { context } from "aws-lambda-mock-context";
import * as Alexa from "alexa-sdk";
const launchRequestJson: any = {
request: {
locale: "en-US",
requestId: "amzn1.echo-api.request.[unique-value-here]",
timestamp: "2016-10-27T18:21:44Z",
type: "LaunchRequest",
},
session: {
application: {applicationId: "amzn1.ask.skill.[unique-value-here]"},
attributes: {},
new: false,
sessionId: "amzn1.echo-api.session.[unique-value-here]",
user: {userId: "amzn1.ask.account.[unique-value-here]"},
},
version: "1.0",
};
const ctx = context();
const alexa = Alexa.handler(launchRequestJson, ctx);
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for AWS Lambda Mock Context SDK 1.0
// Project: https://github.com/moskalyk/typed-aws-lambda-mock-context
// Definitions by: Morgan Moskalyk <morgan.moskalyk@gmail.com>, Anand Nimkar <anand.a.nimkar@gmail.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function context(options?: Options): Context;
interface Context {
Promise: Promise<any>;
callbackWaitsForEmptyEventLoop: boolean;
functionName: string;
functionVersion: string;
invokedFunctionArn: string;
memoryLimitInMB: string;
awsRequestId: string;
invokeid: string;
logGroupName: string;
logStreamName: string;
getRemainingTimeInMillis: number;
succeed(result: any): Promise<any>;
fail(err: any): Promise<any>;
done(err: any, result: any): Promise<any>;
}
interface Options {
region: string;
account: string;
functionName: string;
functionVersion: string;
memoryLimitInMB: string;
alias?: string;
}
export { context };
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"aws-lambda-mock-context-tests.ts"
]
}
@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}