-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (27 loc) · 851 Bytes
/
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
// Starting point for node.js server
// node_modules requires
var express = require('express');
var mongo = require('mongoose');
var bodyParser = require('body-parser');
// My requires
var config = require('./config');
var routes = require('./routes');
// Setup servers and listeners
var app = express();
// To get req.body to be usable
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(routes);
app.use(express.static('./ng_app'));
mongo.connection.on('open', function () {
console.log("Connected to mongo DB");
});
mongo.connection.on('error', function (err) {
console.error("Error connecting to mongo DB");
console.error(err);
});
// Setup database
mongo.connect(config.dbUri);
// Start looking for http requests
app.listen(config.port);
console.log("Listening on port " + config.port + " :)");