-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (28 loc) · 964 Bytes
/
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
var express = require('express');
var path = require('path');
var app = express();
var mongoose = require('mongoose');
var url = "mongodb://localhost:27017/ExpenseList";
mongoose.connect(url);
var db = mongoose.connection;
db.once('open', function(){
console.log("Connected to MongoDB...");
}).on('error', function(error){
console.log("MongoDB Connection Error...", error);
});
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
var cat = require('./server/routes/categories');
var newcat = require('./server/routes/newcat');
var newexp = require('./server/routes/newexp');
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/', cat);
app.use('/', newcat);
app.use('/', newexp);
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
app.listen(3000, function(){
console.log("Server is now listening to port 3000...");
});