This repository has been archived by the owner on Sep 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (43 loc) · 1.62 KB
/
app.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
var express = require('express'),
app = express(),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
mongoose = require('mongoose'),
LocalStrategy = require('passport-local'),
passport = require('passport');
var Psychologist = require('./models/psychologist');
var authPsyRoutes = require('./controller/authpsy'),
stdRoutes = require('./controller/student'),
scheduleRoutes= require('./controller/schedule'),
indexRoutes = require('./controller/index');
app.use(cookieParser());
app.use(require("express-session")({
key: "user_sid",
secret: "II3120 - IT Services",
resave: false,
saveUninitialized: false,
cookie: {
expires: 600000
}
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(Psychologist.authenticate()));
passport.serializeUser(Psychologist.serializeUser());
passport.deserializeUser(Psychologist.deserializeUser());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(__dirname + "/views"));
app.set("view engine", "ejs");
mongoose.connect(process.env.database_uri || "mongodb://localhost/lbk", { useNewUrlParser: true });
app.get("/", function (req, res) {
res.render("index", { account: "" });
});
app.use("/", indexRoutes);
app.use("/student", stdRoutes);
app.use("/psychologist", authPsyRoutes);
app.use("/schedule", scheduleRoutes);
//LOGIN AND AUTH FOR PSYCHOLOGISTS
app.listen(process.env.PORT || 3120, function (req, res) {
console.log("App is running");
console.log("Database running: ", (process.env.database_uri || "mongodb://localhost/lbk"))
})