forked from openhab/openhab-google-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (34 loc) · 956 Bytes
/
server.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
'use strict';
const argv = require('yargs')
.option('oh-host', {
alias: 'h',
describe: 'openHAB Cloud host',
type: 'string',
demandOption: true
})
.option('oh-port', {
describe: 'openHAB Cloud port',
type: 'number',
default: 443
})
.option('oh-path', {
describe: 'openHAB Cloud path',
type: 'string',
default: '/rest/items/'
})
.option('port', {
describe: 'Local listening port',
type: 'number',
default: 3000
})
.help().argv;
const gaConfig = require('openhab.google-assistant-smarthome.cloud-function/config');
gaConfig.host = argv.ohHost;
gaConfig.port = argv.ohPort;
gaConfig.path = argv.ohPath;
const ga = require('openhab.google-assistant-smarthome.cloud-function');
const express = require('express');
const app = express().use(express.json()).use('/', ga.openhabGoogleAssistant);
app.listen(argv.port, () => {
console.log(`Server is listening on port ${argv.port}`);
});