-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.ts
30 lines (28 loc) · 938 Bytes
/
main.ts
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
import { defaultLoggerEnv } from "./lib/src/common/logger.ts";
import { LOG_LEVEL_DEBUG } from "./lib/src/common/logger.ts";
import { Hub } from "./Hub.ts";
import { Config } from "./types.ts";
import { parse } from "https://deno.land/[email protected]/flags/mod.ts";
const KEY = "LSB_"
defaultLoggerEnv.minLogLevel = LOG_LEVEL_DEBUG;
const configFile = Deno.env.get(`${KEY}CONFIG`) || "./dat/config.json";
console.log("LiveSync Bridge is now starting...");
let config: Config = { peers: [] };
const flags = parse(Deno.args, {
boolean: ["reset"],
// string: ["version"],
default: { reset: false },
});
if (flags.reset) {
localStorage.clear();
}
try {
const confText = await Deno.readTextFile(configFile);
config = JSON.parse(confText);
} catch (ex) {
console.error("Could not parse configuration!");
console.error(ex);
}
console.log("LiveSync Bridge is now started!");
const hub = new Hub(config);
hub.start();