-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
executable file
·30 lines (24 loc) · 780 Bytes
/
app.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
'use strict';
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const bearerToken = require('express-bearer-token');
const mongoDb = require('mongodb');
const port = process.env.PORT || 8080;
app.use(bodyParser.json());
app.use(bearerToken());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/app_client'));
mongoDb
.connect(process.env.MONOGO_URL || 'mongodb://@localhost:27017/local')
.then(db => {
app.set('database', db);
require('./api/routes')(app);
app.listen(port);
console.log('Started server on port ' + port);
return app;
})
.catch(console.error);
module.exports = app;