-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (34 loc) · 1.44 KB
/
index.js
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
42
43
44
45
46
47
48
49
50
'use strict';
/***********
modules
********* */
const Alexa = require("alexa-sdk");
const config = require("config.json")("./config/config.json");
const builtInHandler = require('./handlers/builtIn');
const errorHandler = require('./handlers/error');
const gatewayHandler = require('./handlers/gateway');
const groupHandler = require('./handlers/group');
const lightPropertyHandler = require('./handlers/light_property');
const lightHandler = require('./handlers/light');
const sessionHandler = require('./handlers/session');
const unitSpaceHandler = require('./handlers/unit_space');
const makeGatewayURL = require('./js/make_gateway_URL');
// Alexa Skill application
global.APP_NAME = config.alexa.appName;
const APP_ID = config.alexa.appId;
const tableName = config.aws.dynamoDB.table.name;
// TEMP Gateway IP URL
global.BASE_URL = makeGatewayURL(config.sl.gw.ip, config.sl.gw.port, config.sl.gw.version);
// true, false
global.DISPLAY_MODE = config.alexa.skill.setting.displayMode;
// "MQTT", "REST"
global.PROTOCOL = config.alexa.skill.setting.protocol;
// entry
exports.handler = function(event, context, callback) {
//console.log(event);
const alexa = Alexa.handler(event, context);
alexa.appId = APP_ID;
alexa.dynamoDBTableName = tableName;
alexa.registerHandlers(builtInHandler, errorHandler, gatewayHandler, groupHandler, lightPropertyHandler, lightHandler, sessionHandler, unitSpaceHandler);
alexa.execute();
};// exports.handler