-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·44 lines (36 loc) · 1.22 KB
/
server.js
File metadata and controls
executable file
·44 lines (36 loc) · 1.22 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
#!/usr/bin/env node
const argv = require('minimist')(process.argv.slice(2));
const app = require('express')();
const config = require('./config/main');
const router = require('./router')
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const logger = require('morgan');
if (argv.h || argv.help) {
console.log([
'',
' Usage: server.js [options]',
'',
' Options:',
'',
' -h, --help output usage information',
'',
].join('\n'));
process.exit(0);
}
// Database Setup
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/burner', {useMongoClient: true})
.then(() => {
// Setting up basic middleware for all Express requests
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(logger('dev'));
// Import routes to be served
router(app); //require('./routes')(app, {});
// Start server
app.listen((config.port || 8000), () => {
console.log(`Listening on port: ${config.port}`);
});
})
.catch((err) => console.error(err));