-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·76 lines (65 loc) · 2.21 KB
/
app.js
File metadata and controls
executable file
·76 lines (65 loc) · 2.21 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* @name mongomin
* @description Mongo DB admin by Symatic Solutions
* @license GPL-3.0
* @copyright Copyright(c) 2016 Symatic Solutions
*/
var chalk = require('chalk'),
fs = require('fs'),
prompt = require('prompt'),
mongomin = require('./lib/mongomin');
console.log(chalk.green.bold("> Mongomin Started."));
// Check if config.json file is exist.
// If not exist create one with user inputs.
fs.exists('config.json', function(isExist){
if(isExist){
fs.readFile('config.json', function(err, data){
// Set config data to mongomin
mongomin.setConfig(data.toString());
console.log("> Config data fetched.");
// Initialize mongomin application
mongomin.init();
});
}else{
console.log(chalk.red("> Configuration file missing."));
console.log("> Getting connection parameters.\n");
prompt.message = chalk.green.bold("mongomin");
prompt.start();
prompt.get({
properties: {
host: {
description: chalk.blue("mongoDB Host Name"),
default: '127.0.0.1'
},
port: {
description: chalk.blue("mongoDB Port"),
default: '27017'
},
username: {
description: chalk.blue("mongoDB Username"),
default: ''
},
password: {
description: chalk.blue("mongoDB Password"),
default: ''
}
}
}, function (err, data) {
data = {
mongo: data,
mongomin: {
isSSL: false,
host: 'localhost',
port: '9386'
}
};
fs.writeFile('config.json', JSON.stringify(data), function(){
console.log("> Connection parameters written to config.json file.");
// Set config data to mongomin
mongomin.setConfig(JSON.stringify(data));
// Initialize mongomin application
mongomin.init();
});
});
}
});