-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 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
38
39
require('dotenv').config();
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const errorHandler = require('errorhandler');
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect(process.env.DB_URL);
const passport = require('passport');
const { diveRouter, authRouter } = require('./routes');
const port = process.env.PORT || 5000;
const app = express();
/**
* Passport
*/
require('./config/passport')(passport)
app.use(passport.initialize());
app.use(passport.session());
app.use(logger('dev'));
app.use(express.static(path.join(__dirname, 'public')))
app.use(bodyParser.json());
app.use(cookieParser());
app.use('/dives', diveRouter);
app.use('/auth', authRouter)
app.use(errorHandler());
/**
* Launch
*/
app.listen(port, () => console.log(`Server is running at the port ${port}`));