forked from mozilla/blurts-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
49 lines (39 loc) · 1.29 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
"use strict";
const AppConstants = require("./app-constants");
const express = require("express");
const hbs = require("express-hbs");
const sessions = require("client-sessions");
const EmailUtils = require("./email-utils");
const HBSHelpers = require("./hbs-helpers");
const HIBPRoutes = require("./routes/hibp-stubs");
const HomeRoutes = require("./routes/home");
const OAuthRoutes = require("./routes/oauth");
const ScanRoutes = require("./routes/scan");
const UserRoutes = require("./routes/user");
const app = express();
app.use(express.static("public"));
app.engine("hbs", hbs.express4({
layoutsDir: __dirname + "/views/layouts",
partialsDir: __dirname + "/views/partials",
}));
app.set("view engine", "hbs");
app.set("views", __dirname + "/views");
HBSHelpers.init(hbs);
app.use(sessions({
cookieName: "session",
secret: AppConstants.COOKIE_SECRET,
duration: 15 * 60 * 1000, // 15 minutes
activeDuration: 5 * 60 * 1000, // 5 minutes
}));
app.use("/", HomeRoutes);
app.use("/hibp", HIBPRoutes);
app.use("/oauth", OAuthRoutes);
app.use("/scan", ScanRoutes);
app.use("/user", UserRoutes);
EmailUtils.init().then(() => {
const listener = app.listen(AppConstants.PORT, () => {
console.info(`Listening on ${listener.address().port}`);
});
}).catch(error => {
console.error(error);
});