This repository has been archived by the owner on Mar 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
65 lines (58 loc) · 1.73 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path');
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
const passport = require('passport');
const mongoose = require('mongoose');
//const key=require('./config/keys')
const bodyParser = require('body-parser');
const flash=require('connect-flash');
const nev=require('email-verification')(mongoose);
const nodemailer=require('nodemailer')
var transport=nodemailer.createTransport({
service:'Gmail',
auth:{
'user':"[email protected]",
pass:'coursecritique1'
}
})
mongoose.connect(process.env.MONGODB_URI);
app.set('views',__dirname+'/frontend');
app.set('view engine','ejs')
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.use(require('cookie-parser')());
app.use(require('cookie-session')({
name:"session",
keys:['key1'],
maxAge:2*3600*1000
}));
app.use(bodyParser.json());
app.use(passport.initialize());
app.use(passport.session());
app.use(flash())
app.use(express.static(path.join(__dirname, 'public')));
require('./config/nev.js')(nev);
require('./config/passport.js')(passport);
require('./backend/appRoutes')(app,passport,nev,transport);
app.get('*', (request, response) => {
response.sendFile(__dirname + '/public/index.html'); // For React/Redux
});
// app.use(function(err,req,res,next){
// if(err.status&&err.status>100&err.status<500){
// res.status(err.status)
// }
// else{
// res.status(500)
// }
// res.json({error:{
// error:err,
// message:err.message,
// stack:err.stack
// }})
// })
app.listen(PORT, error => {
error
? console.error(error)
: console.info(`==> 🌎 Listening on port ${PORT}. Visit http://localhost:${PORT}/ in your browser.`);
});