-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js.save
executable file
·84 lines (71 loc) · 2.64 KB
/
app.js.save
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var express = require("express"),
app = express(),
bodyParser = require("body-parser"),
mongoose = require("mongoose"),
passport = require("passport"),
cookieParser = require("cookie-parser"),
LocalStrategy = require("passport-local"),
flash = require("connect-flash"),
session = require("express-session"),
methodOverride = require("method-override");
mongoose.Promise = global.Promise;
var groupRoutes = require("./routes/group"),
dashboardRoutes = require("./routes/dashboard"),
adminRoutes = require("./routes/admin"),
problemRoutes = require("./routes/problems"),
tagRoutes = require("./routes/tag"),
indexRoutes = require("./routes/index"),
User = require("./models/user"),
competitionRoutes = require("./routes/competition"),
userRoutes = require("./routes/user");
//const templates = `./middleware/mailTemplates/`;
//mailer.sendTemplateTo(templates + `welcome`, {address: `google.com`}, `[email protected]`, (err, info) => {
//console.log(`Sent`);
//console.log(err);
console.log(info);
});
// const mailer = require('./middleware/mailSender');
// const templates = `./middleware/mailTemplates/`;
// mailer.sendTemplateTo(templates + `welcome`, {address:`google.com`}, `[email protected]`, (err, info) => {
// console.log(`Sent`);
// console.log(err);
// console.log(info)
// });
mongoose.connect("mongodb://localhost/DMC");
app.use(bodyParser.urlencoded({extended: true}));
app.set("view engine", "ejs");
app.use(express.static(__dirname + "/public"));
app.use(methodOverride('_method'));
app.use(cookieParser('secret'));
// PASSPORT CONFIGURATION
app.use(require("express-session")({
secret: "Once again Rusty wins cutest dog!",
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
require('./config/passport')(passport);
app.use(function(req, res, next){
app.locals.currentUser = req.user;
res.locals.success = req.flash('success');
res.locals.error = req.flash('error');
next();
});
app.use("/", indexRoutes);
app.use("/admin/", groupRoutes);
app.use("/admin/", competitionRoutes);
app.use("/dashboard", dashboardRoutes);
app.use("/admin/", adminRoutes);
app.use("/admin/users", userRoutes);
app.use("/admin/problems", problemRoutes);
app.use("/admin/tags", tagRoutes);
app.use(function(req, res, next) {
res.status(404).send('Sorry cant find that!');
});
var server = app.listen(3002, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Survey listening at http://%s:%s', host, port);
});