-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
executable file
·54 lines (50 loc) · 1.21 KB
/
index.mjs
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
#!/usr/bin/env -S SUPPRESS_NO_CONFIG_WARNING=true node --experimental-json-modules
import { getPort, readConf } from './utils.mjs';
import path from 'path';
import start from './server.mjs';
import yargs from 'yargs';
const PORT = 10000;
(async () => {
const port = await getPort(PORT);
const { argv } = yargs(process.argv)
.usage('$0 [-chpr]')
.options({
c: {
alias: 'cert',
default: readConf('cert', 'cert'),
describe: 'https certificates folder',
type: 'string',
},
h: {
alias: 'host',
default: readConf('host', 'localhost'),
describe: 'server host name',
type: 'string',
},
p: {
alias: 'port',
default: readConf('port', port),
describe: 'preferred server port',
type: 'number',
},
r: {
alias: 'root',
default: path.resolve(),
describe: 'root folder',
type: 'string',
},
s: {
alias: 'stream',
describe: 'stream files instead of saving them on a disk',
type: 'boolean',
},
})
.help();
start({
CERT: argv.c,
HOST: argv.h,
PORT: argv.p,
ROOT: argv.r,
STREAM: argv.s,
});
})();