-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (25 loc) · 808 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
31
32
33
const express = require('express'),
bodyParser = require('body-parser'),
mongoose = require('mongoose'),
initializeOauth = require('./middleware/authServer'),
authenticateRequest = require('./middleware/authenticator');
var app = express();
const authenticationRoutes = require('./routes/oauth');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.oauth = initializeOauth;
app.use(authenticationRoutes);
app.get('/', authenticateRequest, function(req, res) {
res.send('Secret area');
});
mongoose
.connect(process.env.DATABASE, {
useCreateIndex: true,
useNewUrlParser: true
})
.then(result => {
// console.log(result)
console.log('connected');
app.listen(process.env.PORT || 3000);
})
.catch(err => console.log('error', err));