-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
27 lines (26 loc) · 888 Bytes
/
server.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
const express=require('express');
const app=express();
const mongoose=require('mongoose');
const key=require('./config/keys.js')
const users=require('./routes/api/users')
const post=require('./routes/api/post')
const profile=require('./routes/api/profile.js')
const bodyParser=require('body-parser')
const passport=require('passport')
const session=require('express-session')
mongoose.connect(key.mongoURL,{ useNewUrlParser: true },()=>{
console.log("DATABASE CONNECTED")
})
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(session({ secret: 'SECRET' }));
app.use(passport.initialize());
app.use(passport.session());
require('./config/passport.js')(passport);
app.use('/api/users',users)
app.use('/api/post',post)
app.use('/api/profile',profile)
var port=process.env.port||5000;
app.listen(port,()=>{
console.log(`Server running on ${port}`)
})