-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
59 lines (49 loc) · 1.68 KB
/
Copy pathapp.js
File metadata and controls
59 lines (49 loc) · 1.68 KB
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
51
52
53
54
55
56
57
58
59
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import SdrTrunkApi from './modules/SdrTrunkApi.js';
import WebServer from './modules/WebServer.js';
import {loadConfig} from './modules/configLoader.js';
import UdpReceiver from './modules/UdpReceiver.js';
import path from 'path';
import { fileURLToPath } from 'url';
import WhackerLinkInterface from "./modules/WhackerLinkInterface.js";
const argv = yargs(hideBin(process.argv))
.option('c', {
alias: 'config',
describe: 'Path to config file',
type: 'string',
})
.help()
.alias('help', 'h')
.argv;
// Template for config object
let config = {
web: {},
sdrtrunk: {},
whackerlink: {},
discord: null,
systems: []
};
if (argv.config) {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const config = loadConfig(argv.config);
const baseUploadPath = path.join(__dirname, 'uploads');
const webServer = new WebServer(config);
// if ((!config.sdrtrunk || !config.sdrtrunk.enabled) && (!config.udp || !config.udp.receive.enabled)) {
// console.log('SDRTrunk or UDP not enabled or no config found for them; Must have at least one API for this to be useful');
// process.exit(1);
// }
if (config.sdrtrunk.enabled) {
new SdrTrunkApi(webServer.io, config, baseUploadPath);
}
if (config.udp.receive.enabled) {
new UdpReceiver(webServer.io, config, baseUploadPath);
}
if (config.whackerlink && config.whackerlink.enabled) {
new WhackerLinkInterface(webServer.io, config);
}
} else {
console.error('No config file specified');
process.exit(1);
}