forked from necroscope/addictldapwebclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·49 lines (42 loc) · 1.31 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
const AD = require('ad');
const express = require("express");
const bodyParser = require('body-parser');
const swagpi = require('swagpi');
const vorpal = require('vorpal')();
const swagpiConfig = require('./src/swagpi.config.js');
const loadConfig = require('./src/loadConfig');
const routes = require('./src/routes');
const commands = require('./src/commands');
const middleware = require('./middleware');
const chalk = vorpal.chalk;
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
middleware.call(app);
swagpi(app, {
logo: './src/img/logo.png',
config: swagpiConfig
});
const init = (args) => {
try {
const config = loadConfig(args);
const ad = new AD(config).cache(true);
app.listen(process.env.PORT || 3000);
routes(app, config, ad);
vorpal.use(commands, {ad});
} catch(err) {
vorpal.log(err.message);
process.exit();
}
}
vorpal.command('_start')
.hidden()
.option('-u, --user [user]', 'Domain admin username.')
.option('-p, --pass [pass]', 'Domain admin password.')
.option('--url [url]', 'URL for Active Directory.')
.action(function(args, cbk) {
init(args);
cbk();
})
vorpal.exec(`_start ${process.argv.slice(2).join(' ')}`);
vorpal.log('\nAddict Active Directory API\n');
vorpal.delimiter(chalk.cyan('Addict:')).show();