-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathroutesLocal.js
81 lines (69 loc) · 2.02 KB
/
routesLocal.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
const proxy = require("express-http-proxy");
const serverFunctions = require("./lib/serverFunctions");
const locals = require("./constants/local");
const localId = process.env.LOCAL_ID;
const local = locals["LOCALS"][localId];
const dynamicRoutes = local.routes ? local.routes : null;
module.exports.dynamic = (app, server) => {
if (local.routes) {
server.get(Object.keys(dynamicRoutes), (req, res) => {
const actualPage = "/local/markdown";
serverFunctions.renderAndCache(app, req, res, actualPage, req.query);
});
}
};
module.exports.static = (app, server) => {
server.get("/", (req, res) => {
const actualPage = "/local";
serverFunctions.renderAndCache(app, req, res, actualPage, req.query);
});
// lists routes
server.get("/lists/:list", (req, res) => {
const actualPage = "/lists/list";
const params = {
list: req.params.list
};
serverFunctions.renderAndCache(
app,
req,
res,
actualPage,
req.query,
params
);
});
server.get("/lists", (req, res) => {
const actualPage = "/lists";
serverFunctions.renderAndCache(app, req, res, actualPage, req.query);
});
// search routes
server.get(["/search", "/search"], (req, res) => {
// need this because the search API doesn't recognize "all" but we need
// to pass some value in through the select on the homepage
if (req.query["type"] && req.query["type"] === "all") {
delete req.query["type"];
}
const actualPage = "/search";
serverFunctions.renderAndCache(app, req, res, actualPage, req.query);
});
server.get("/browse-by-partner", (req, res) => {
app.render(req, res, "/browse-by-partner", req.query);
});
// item routes
server.get("/item/:itemId", (req, res) => {
const actualPage = "/item";
const isQA = "qa" in req.cookies;
const params = {
itemId: req.params.itemId,
isQA: isQA
};
serverFunctions.renderAndCache(
app,
req,
res,
actualPage,
req.query,
params
);
});
};