-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 1.07 KB
/
index.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");
const bodyParser = require("body-parser");
const mongoose = require('mongoose');
const cookieParser = require("cookie-parser");
const passport = require('./config/passport');
const session = require('express-session');
const winston = require('winston');
const expressWinston = require('express-winston');
require('dotenv/config');
const app=express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
mongoose.connect(process.env.MONGO_DB_CONN_STRING,
{
useNewUrlParser: true,
useUnifiedTopology: true
}
).then(()=>{
console.log("connected to db");
});
//configuring the express app
app.use(cookieParser(process.env.SECRET));
app.use(passport.initialize());
//configuring routers
app.use('/test', express.static(__dirname+'/tests'));
app.use('/post', require('./routes/postRoute'));
app.use('/', require('./routes/userRoute'));
app.listen(process.env.PORT, console.log((process.env.ENVIORNMENT==="DEV")?`listening on http://localhost:${process.env.PORT}/`:"https://bll-webd-select.herokuapp.com/"))