-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
37 lines (31 loc) · 972 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
28
29
30
31
32
33
34
35
36
37
const mongoose = require('mongoose');
const express = require('express');
const cors = require('cors');
const morgan = require('morgan');
const passport = require('passport');
const bodyParser = require('body-parser');
const session = require('express-session');
const ejs = require('ejs');
const auth = require('./controller/auth.js');
const routes = require('./routes/routes');
const config = require('./config/database');
mongoose.connect(config.database);
mongoose.connection.on('open', () => {
console.log('Mongo is connected');
const app = express();
app.use(morgan('dev'));
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(session({
secret: 'Super Secret Session Key',
saveUninitialized: true,
resave: true,
}));
app.set('view engine', 'ejs');
app.use(routes);
app.use(passport.initialize());
app.listen(3333, () => {
console.log('server is running');
});
});