-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
54 lines (46 loc) · 1.23 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
45
46
47
48
49
50
51
52
53
54
'use strict';
import { neutron } from '@arlojay-studios/neutron-atomic'
import { protonDB } from '@arlojay-studios/proton-atomic';
/**
* Init
* @param {Number} port
* Which port the server will run on.
* Usage: --port [port]
* @param {Boolean} parity
* Whether or not the server will be used as a backup. Data retention is 7 days.
* Usage: --parity [true|false]
* @param {String} dbPath
* Where the DB resides on the file system
* Usage: --db ['/path/to/db']
* @private
*/
const argv = require('minimist')(process.argv.slice(1), {
'default': {
'port': 3000,
'parity': false,
'db': './db/users.db'
}
});
/**
* Server / DB Init
* @param {String} dbPath
* @param {String} port
* @returns {protonDB}
*/
export class Wrapper {
private server: neutron;
constructor(dbPath: string) {
this.server = new neutron(dbPath);
}
public main(port: number): Promise<[Express.Application, protonDB] | string> {
return new Promise(async (resolve, reject) => {
try {
resolve(await this.server.init(port));
} catch (err) {
reject(err);
}
})
}
}
const atomic = new Wrapper(argv.db);
atomic.main(argv.port)