-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (30 loc) · 781 Bytes
/
app.js
File metadata and controls
38 lines (30 loc) · 781 Bytes
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
'use strict';
const http = require('http');
const express = require('express');
const nconf = require('nconf');
const mongoose = require('mongoose');
const debug = require('debug')('server:app');
const appModule = require('app');
const app = express();
const server = http.createServer(app);
nconf
.argv()
.env()
.file({
file: './config.json',
});
app.use(express.static('public'));
app.use(appModule.router);
const dbUrl = nconf.get('DB_URL');
const webOptions = {
port: nconf.get('WEB_PORT'),
host: nconf.get('WEB_HOST'),
};
mongoose.connect(dbUrl);
const db = mongoose.connection;
db.once('open', () => {
debug(`established mongoDB connection to ${dbUrl}`);
});
server.listen(webOptions, () => {
debug(`Server listening on: ${webOptions.port}`);
});