forked from Rahul-Bisht/mailit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·55 lines (46 loc) · 1.57 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
const express = require('express');
const bodyParser = require('body-parser');
const vorpal = require('vorpal')();
const swagpi = require('swagpi');
const chalk = vorpal.chalk;
const swagpiConfig = require('./src/swagpi.config.js');
const middleware = require('./middleware');
const loadConfig = require('./src/util/loadConfig');
const routes = require('./src/routes');
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
middleware.call(app);
swagpi(app, {
logo: './src/img/logo.png',
css: 'img { width: 96px !important; margin-top: 8px !important; }',
config: swagpiConfig
});
const init = (args) => {
try {
const config = loadConfig(args);
app.listen(config.webPort || 3000);
routes(app, config);
} catch(err) {
vorpal.log(err.message);
process.exit();
}
}
vorpal.command('_start')
.hidden()
.option('--webPort [number]', 'Port for API to listen on.')
.option('-c, --config [path]', 'Path to config.json.')
.option('-h, --host [host]', 'SMTP host.')
.option('--port [port]', 'SMTP port.')
.option('-u, --user [user]', 'SMTP user account.')
.option('-p, --pass [pass]', 'SMTP email password.')
.option('-s, --secure [secure]', 'Whether to use an encrypted connection.')
.option('--rejectUnauthorized [boolean]', 'Whether to reject an unauthorized TLS cert.')
.option('--url [url]', 'URL for Active Directory.')
.action(function(args, cbk) {
init(args);
cbk();
});
vorpal.log(' MailIt SMTP API');
vorpal.exec(`_start ${process.argv.slice(2).join(' ')}`);
vorpal.delimiter(chalk.cyan('Mail') + chalk.grey('It:'));