add initial handler, request and context

This commit is contained in:
petebeegle
2016-08-02 21:58:15 -04:00
parent b5810365ac
commit 69eb72614d
2 changed files with 39 additions and 8 deletions

View File

@@ -1,10 +1,9 @@
/// <reference path="../node/node.d.ts"/>
/// <reference path="./alexa-sdk.d.ts" />
'use strict';
import Alexa = require("alexa-sdk");
exports.handler = function(event, context, callback) {
exports.handler = function(event: Alexa.Request, context: Alexa.Context, callback) {
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
@@ -15,9 +14,9 @@ var handlers = {
this.emit('SayHello');
},
'HelloWorldIntent': function () {
this.emit('SayHello')
this.emit('SayHello');
},
'SayHello': function () {
this.emit(':tell', 'Hello World!');
}
};
};

View File

@@ -4,7 +4,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'alexa-sdk' {
var handler: (event: any, context: any, callback?: any) => AlexaHandler;
export function handler(event: Request, context: Context, callback?: () => void): AlexaHandler;
export function CreateStateHandler(state: string, obj: any): any;
export var StateString: string;
interface AlexaHandler {
_event: any;
@@ -14,8 +16,38 @@ declare module 'alexa-sdk' {
appId: any;
response: any;
dynamoDBTableName: any;
saveBeforeResponse: any;
registerHandlers: any;
execute: any;
saveBeforeResponse: boolean;
registerHandlers: (...handlers: any[]) => any;
execute: () => void;
}
interface Handler {
on: any;
emit: any;
emitWithState: any;
state: any;
handler: any;
event: any;
attributes: any;
context: any;
name: any;
isOverriden: any;
}
interface Request {
version: string;
request: any;
session: any;
}
interface Context {
callbackWaitsForEmptyEventLoop: boolean;
logGroupName: string;
logStreamName: string;
functionName: string;
memoryLimitInMB: string;
functionVersion: string;
invokeid: string;
awsRequestId: string;
}
}