forked from mjzone/cicd-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (25 loc) · 814 Bytes
/
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
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.status(200).send("OK");
});
app.get("/app01", (req, res) => {
console.log(getTimestampLog() + " procesando peticion...");
res.send("Hola Comunidad!");
});
app.get("/app01/cncf", (req, res) => {
res.send("Hola Comunidad CNCF!");
});
app.get("/app01/health", (req, res) => {
res.send("UP");
});
app.get("/app01/dashboard", (req, res) => {
console.log(getTimestampLog() + " trying to access dashboard without login...");
res.status(401).send("Unauthorized");
});
app.listen(3000, () => {
console.log("App listening on port 3000!");
});
function getTimestampLog() {
return new Date((dt = new Date()).getTime() - dt.getTimezoneOffset() * 60000).toISOString().replace(/(.*)T(.*)\..*/,'$1 $2');
}