-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
127 lines (121 loc) · 3.6 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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright (c) 2020, 2021, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
const path = require("path");
const express = require("express");
const port = 8000;
const app = express();
const staticPath = path.join(__dirname, "web");
const apiUrl = process.env.VZ_API_URL;
if (!apiUrl) {
throw new Error("VZ_API_URL not specified. Aborting..");
}
app.use(express.static(staticPath));
app.get("/oamapps", (req, res, next) => {
res.redirect(
`/?ojr=instance&selectedItem=oamapps${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/oamcomps", (req, res, next) => {
res.redirect(
`/?ojr=instance&selectedItem=oamcomps${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/projects", (req, res, next) => {
res.redirect(`/?ojr=instance&selectedItem=projects`);
});
app.get("/weblogicimages", (req, res, next) => {
res.redirect(
`/?ojr=instance&selectedItem=weblogicimages${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/oamapps/:id", (req, res, next) => {
res.redirect(
`/?ojr=oamapp&oamAppId=${req.params.id}${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/oamcomps/:id", (req, res, next) => {
res.redirect(
`/?ojr=oamcomp&oamCompId=${req.params.id}${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/projects/:id", (req, res, next) => {
res.redirect(`/?ojr=project&projectId=${req.params.id}`);
});
app.get("/oamapps/:id/components", (req, res, next) => {
res.redirect(
`/?ojr=oamapp&oamAppId=${req.params.id}&selectedItem=components${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
});
app.get("/oamapps/:id/components/:selectedComponent", (req, res, next) => {
res.redirect(
`/?ojr=oamapp&oamAppId=${
req.params.id
}&selectedItem=components&selectedComponent=${
req.params.selectedComponent
}${req.query.cluster ? "&cluster=" + req.query.cluster : ""}`
);
});
app.get(
"/oamapps/:id/components/:selectedComponent/:selectedItem",
(req, res, next) => {
res.redirect(
`/?ojr=oamapp&oamAppId=${req.params.id}&selectedItem=${
req.params.selectedItem
}&selectedComponent=${req.params.selectedComponent}${
req.query.cluster ? "&cluster=" + req.query.cluster : ""
}`
);
}
);
app.get("/oamcomps/:id/:selectedItem", (req, res, next) => {
res.redirect(
`/?ojr=oamcomp&oamCompId=${req.params.id}&selectedItem=${
req.params.selectedItem
}${req.query.cluster ? "&cluster=" + req.query.cluster : ""}`
);
});
app.get("/projects/:id/namespaces", (req, res, next) => {
res.redirect(
`/?ojr=project&projectId=${req.params.id}&selectedItem=namespaces`
);
});
app.get("/projects/:id/clusters", (req, res, next) => {
res.redirect(
`/?ojr=project&projectId=${req.params.id}&selectedItem=clusters`
);
});
app.get("/projects/:id/security", (req, res, next) => {
res.redirect(
`/?ojr=project&projectId=${req.params.id}&selectedItem=security`
);
});
app.get("/projects/:id/networkPolicies", (req, res, next) => {
res.redirect(
`/?ojr=project&projectId=${req.params.id}&selectedItem=networkPolicies`
);
});
app.get("/clusters", (req, res, next) => {
res.redirect("/?ojr=instance&selectedItem=clusters");
});
app.listen(port, "0.0.0.0", function onStart(err) {
if (err) {
console.log(err);
}
console.info(
"==>Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.",
port,
port
);
});