forked from open-telemetry/opentelemetry-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (37 loc) · 1 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
"use strict";
const PORT = process.env.PORT || "8080";
const express = require("express");
const axios = require("axios");
const { countAllRequests } = require("./monitoring");
const app = express();
app.use(countAllRequests());
app.get("/", (req, res) => {
axios
.get(`http://localhost:${PORT}/middle-tier`)
.then(() => axios.get(`http://localhost:${PORT}/middle-tier`))
.then(result => {
res.send(result.data);
})
.catch(err => {
console.error(err);
res.status(500).send();
});
});
app.get("/middle-tier", (req, res) => {
axios
.get(`http://localhost:${PORT}/backend`)
.then(() => axios.get(`http://localhost:${PORT}/backend`))
.then(result => {
res.send(result.data);
})
.catch(err => {
console.error(err);
res.status(500).send();
});
});
app.get("/backend", (req, res) => {
res.send("Hello from the backend");
});
app.listen(parseInt(PORT, 10), () => {
console.log(`Listening for requests on http://localhost:${PORT}`);
});