-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
53 lines (39 loc) · 1.14 KB
/
server.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
50
51
52
53
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var moment = require('moment');
var format = require('format');
var methodOverride = require('method-override');
var _ = require('lodash');
var config = require('./config');
// Create the application.
var app = express();
// Add Middleware necessary for REST API's
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(methodOverride('X-HTTP-Method-Override'));
app.use(morgan('dev'));
app.use(express.static(__dirname + '/public'));
var api= require('./app/routes/api')(app,express);
app.use('/api',api);
app.get('*', function(req,res){
res.sendFile(__dirname + '/public/app/views/index.html');
})
mongoose.connect(config.database, function(err){
if(err){
console.log(err);
}else{
console.log("Connected to db");
}
});
app.get('*', function(req,res){
res.sendFile(__dirname + '/public/views/index.html');
})
app.listen(config.port, function(err){
if(err){
console.log(err);
}else{
console.log("Listening")
}
})