-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (30 loc) · 929 Bytes
/
Copy pathserver.js
File metadata and controls
33 lines (30 loc) · 929 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
var mainRouter = require('./routes/index');
var apiRouter = require('./routes/api');
var DB = "mongodb://localhost/interview";
var mongoose = require('mongoose');
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var config = require('./config');
var morgan = require('morgan');
var app = express();
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// app.use('/', mainRouter);
app.use('/api', apiRouter);
mongoose.Promise = global.Promise;
mongoose.connect(DB, function(err) {
if (err) {
return err;
} else {
console.log('Successfully connected to ' + DB);
}
});
app.use(express.static('./static'));
app.get('*', (req, res) => {
res.sendFile(__dirname + '/static/app/views/index.html');
});
app.listen(config.port, function() {
console.log('Listening on port ' + config.port);
});