-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·32 lines (23 loc) · 847 Bytes
/
index.js
File metadata and controls
executable file
·32 lines (23 loc) · 847 Bytes
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
#! /usr/bin/env node
'use strict';
const express = require('express'),
bodyParser = require('body-parser'),
lirc = require('lirc_node');
const Devices = require('./lib/model/devices'),
{assert} = require('./lib/utils/assert'),
{processArgv} = require('./lib/utils/cli'),
httpApi = require('./lib/api/http');
const argsMap = {
port: ['-p', '--port'],
config: ['-c', '--config', '--conf'],
},
args = processArgv(argsMap);
assert(args.config, `Configuration path must be passed via ${argsMap.config.join(', ')} argument.`);
const config = require(args.config);
lirc.init();
const devices = new Devices(config),
app = express(),
port = args.port || 3001;
app.use(bodyParser.json());
app.listen(port, () => console.log(`listening on port ${port}`));
httpApi(app, devices);