-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (19 loc) · 690 Bytes
/
app.js
File metadata and controls
23 lines (19 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const config = require('./config/config'),
express = require('express'),
app = express(),
logger = require('morgan'),
bodyParser = require('body-parser'),
mongoose = require('mongoose'),
User = require('./models/user'),
server = app.listen(config.port),
router = require('./router');
mongoose.connect(config.database, function(error) {
if (error) throw error;
console.log('Database connected to', config.database);
console.log('App is running on port', config.port);
});
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
// Route all API calls through /api
app.use('/api', router);
module.exports = app;