-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
84 lines (69 loc) · 2.25 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const express = require("express");
const cookieParser = require("cookie-parser");
const port = 3000;
const expressLayout = require("express-ejs-layouts");
const app = express();
const db = require("./config/mongoose");
// Used for Session Cookies
const session = require("express-session");
// Using Passport js Strategy
const passport = require("passport");
const passportLocal = require("./config/passport-local-strategy");
const passportJWT = require('./config/passport-jwt-strategy');
const passportGoogle = require('./config/passport-google-oauth2-strategy');
const MongoStore = require("connect-mongo");
const sassMiddleware = require("node-sass-middleware");
const flash = require('connect-flash');
const customWare = require('./config/middleware');
// MiddleWare
app.use(
sassMiddleware({
src: "./assets/scss", // where to look for scss
dest: "./assets/css", // where to deliver the css which is made using scss
debug: false, // this will print errors if any
outputStyle: "extended", // similar to word-wrap thing
prefix: "/css", // unclear concept
})
);
app.use(express.urlencoded());
app.use(expressLayout);
app.use(cookieParser());
app.use(express.static("./assets"));
app.use('/uploads', express.static(__dirname + '/uploads'));
app.set("view engine", "ejs");
app.set("views", "views");
app.set("layout extractScripts", true);
app.set("layout extractStyles", true);
app.use(
session({
name: "codeial",
// TODO change the secret key before Deployment in Production mode
secret: "laterChange",
saveUninitialized: false,
resave: false,
cookie: {
maxAge: 1000 * 60 * 100,
},
store: MongoStore.create({
mongoUrl: "mongodb://localhost/Codeial_development",
dbName: "Codeial_development",
stringify: false,
}),
})
);
app.use(passport.initialize());
app.use(passport.session());
app.use(passport.setAuthenticatedUser);
// Using Flash for showing Noty message
app.use(flash());
app.use(customWare.setFlash);
// Use Express-router
app.use("/", require("./routes/index"));
// server is running on Port successfully or not
app.listen(port, (err) => {
if (err) {
console.log(`Error in running on Port :: ${port}`);
return;
}
console.log(`Server is Running on Port :: ${port}`);
});