-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
40 lines (30 loc) · 1.2 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
const express = require('express');
const dotenv = require('dotenv');
const path = require('path');
const express_sessions = require('express-session');
// const formidable = require('express-formidable');
const passport = require('./passport').passport;
//setting up enviornment
dotenv.config({path: "./config/config.env"});
//connecting to database
require('./config/connection_db').connect_with_MongoDB();
const app = express();
let port = process.env.PORT || 5000;
//decrypting json and urlencoded
app.use(express.json());
app.use(express.urlencoded({extended: true}));
//for form uploads with files
// app.use(formidable());
//initializing passport
app.use(express_sessions({
secret: 'SachinTendulkarIsTheGreatestBatsmanOfAllTime'
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(path.join(__dirname,'public')));
// app.use(express.static(path.join(__dirname,'public')));
app.use('/root',require('./routes/root').route);
app.use('/profile',require('./routes/profile').route);
app.use('/login',require('./routes/login').route);
app.use('/signup',require('./routes/signup').route);
app.listen(port, ()=>{console.log(`Mode: ${process.env.NodeEnv} hosted on port ${port}`)});