This repository has been archived by the owner on Jun 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (48 loc) · 1.72 KB
/
index.js
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
if (process.env.NODE_ENV === 'development') {
require('async-bugs');
}
const chalk = require('chalk');
const minimist = require('minimist');
const packageJson = require('./package.json');
const args = minimist(process.argv);
function showHelp () {
console.log(`
${chalk.green(chalk.bold('📦 Bitabase'))}-${chalk.green('Gateway')} ${chalk.green(`- v${packageJson.version}`)}
The scalable, sharded database engine.
https://docs.bitabase.com
The following commands and arguments are available when starting Bitabase
Commands:
start Start the bitabase gateway stack
--advertise-host Hostname to advertise to others (default: --bind-host)
--bind-host Hostname to bind server to (default: 0.0.0.0)
--bind-port Port to bind server to (default: 8001)
--rqlite-addr Path to contact rqlite
--secret The internal request secret
--account-mapper The regex to take the account from the incoming host (default: (.*).bitabase.test)
`.trim() + '\n');
}
function main () {
if (args.help || args._.length === 2) {
showHelp();
console.log(chalk.red('No command specified'));
process.exit(1);
}
if (args._[2] === 'start') {
const createServer = require('./server');
createServer({
...args,
advertiseHost: args['advertise-host'],
bindHost: args['bind-host'],
bindPort: args['bind-port'],
secret: args.secret,
accountMapper: args['account-mapper'],
rqliteAddr: args['rqlite-addr']
}).start();
return;
}
showHelp();
console.log(args);
console.log(chalk.red(`Unknown command "${args._[2]}"`));
process.exit(1);
}
main();