-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (29 loc) · 1 KB
/
index.js
File metadata and controls
43 lines (29 loc) · 1 KB
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
36
37
38
39
40
41
42
43
const express = require('express');
const mongoose = require('mongoose');
const passport = require('passport');
const bodyParser = require('body-parser');
const path = require('path');
const cors = require('cors');
const app = express();
const config = require('./_config/database');
mongoose.connect(config.database, {useNewUrlParser: true, useUnifiedTopology: true});
mongoose.connection.on('connected', () => {
console.log("Database => " + config.database);
})
mongoose.connection.on('error', (err) =>{
console.log("Database error => " + err);
})
app.use(cors());
app.use(require("./_config/corsheaders"));
app.use(bodyParser.json({limit: '5mb'}));
app.use(express.static(path.join(__dirname + "public")));
app.use(passport.initialize());
app.use(passport.session());
require('./_config/passport')(passport)
const users = require('./_routes/users');
app.use('/users', users);
app.use(passport.initialize());
app.use(passport.session());
app.listen(3000, () => {
console.log("Listening on port 3000");
});