-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
40 lines (37 loc) · 1.03 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
const express = require('express');
const db = require('./libs/db');
const payment = require('./libs/payment');
const info = require('./libs/info');
const bodyParser = require('body-parser');
const app = express();
const argv = require('minimist')(process.argv.slice(2), {
'default': {
'port': 3000,
'host': '0.0.0.0',
'production': false,
},
'alias': {
'port': 'p',
'host': 'h',
'production': 'prod'
}
});
const { port, host, production } = argv;
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.use(express.static('public'));
app.use('/r', db.api);
app.use('/r', payment.api);
app.use('/', info.api);
if (production){
require("greenlock-express")
.init({
packageRoot: __dirname,
maintainerEmail: "[email protected]",
configDir: "./greenlock.d",
cluster: false
})
.serve(app);
}else{
app.listen(port, host, () => console.log(`Server listening on http://${host}:${port}`))
}