-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
48 lines (36 loc) · 1.25 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
require("dotenv").config();
require("./db");
const express = require("express");
const hbs = require("hbs");
const app = express();
// ℹ️ This function is getting exported from the config folder. It runs most pieces of middleware
require("./config")(app);
// Sets the partials directory for handlebars
hbs.registerPartials(__dirname + "/views/partials");
// Configure session
const session = require("express-session");
const MongoStore = require("connect-mongo");
app.use(
session({
secret: process.env.SESSION_SECRET,
cookie: { maxAge: 1000 * 60 * 60 * 24 }, // 1 day
resave: true,
saveUninitialized: true,
store: MongoStore.create({
mongoUrl: process.env.MONGODB_URI,
}),
})
);
app.locals.appTitle = "FamTrack";
// 👇 Start handling routes here
const indexRoutes = require("./routes/index.js");
app.use("/", indexRoutes);
const authRoutes = require("./routes/auth.js");
app.use("/", authRoutes);
const familyRoutes = require("./routes/family.js");
app.use("/", familyRoutes);
const familyMemberRoutes = require("./routes/family-member.js");
app.use("/", familyMemberRoutes);
// ❗ To handle errors. Routes that don't exist or errors that you handle in specific routes
require("./error-handling")(app);
module.exports = app;