-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathindex.ts
44 lines (36 loc) · 1.18 KB
/
index.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import yargs from "yargs";
import {Consola} from "consola"
import NodeRunner from "./src/NodeRunner";
import {NodeConfig} from "./src/types";
import {readJSON} from "./src/utils/objects";
const logger = require("./src/utils/logger")("index") as Consola;
const {hideBin} = require("yargs/helpers") as any;
async function start() {
try {
await main();
} catch (e) {
logger.error(e.stack);
logger.info(
"USAGE: yarn start:prod --config <PATH_TO_CONFIG_FILE>");
}
}
async function main(): Promise<void> {
// Reading cli arguments
const argv = yargs(hideBin(process.argv)).argv;
const configFilePath = argv.config as string;
// Validating cli arguments
if (configFilePath === undefined || configFilePath === "") {
throw new Error("Path to the config file cannot be empty");
}
// TODO: validate config files and manifest files - use json schema? https://2ality.com/2020/06/validating-data-typescript.html
const config: NodeConfig = readJSON(configFilePath);
const jwk = readJSON(config.arweaveKeysFile);
// Running limestone-node with manifest
const runner = await NodeRunner.create(
jwk,
config
);
await runner.run();
}
start();
export = {};