Skip to content

Commit 8069f25

Browse files
committed
chore: add endpoint indicators
1 parent ef5f0cd commit 8069f25

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

src/indicator/HighLoadEndpoint.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const express = require('express');
2+
const router = express.Router();
3+
4+
router.get('/indicator/high-load-four-per-second', (req, res) => {
5+
res.sendStatus(200);
6+
});
7+
8+
router.get('/indicator/high-load-two-per-second', (req, res) => {
9+
res.sendStatus(200);
10+
});
11+
12+
module.exports = router;

src/indicator/SlowEndpoint.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const express = require('express');
2+
const router = express.Router();
3+
4+
router.get('/indicator/slow-2000ms', (req, res) => {
5+
setTimeout(() => {
6+
res.sendStatus(200);
7+
}, 2000);
8+
});
9+
10+
router.get('/indicator/slow-1000ms', (req, res) => {
11+
setTimeout(() => {
12+
res.sendStatus(200);
13+
}, 1000);
14+
});
15+
16+
module.exports = router;

src/indicator/UnusedEndpoint.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const express = require('express');
2+
const router = express.Router();
3+
4+
router.get('/indicator/unused-endpoint', (req, res) => {
5+
res.sendStatus(200);
6+
});
7+
8+
module.exports = router;

src/main.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,34 @@ function startIndicators() {
1313
const express = require('express');
1414

1515
const app = express();
16-
const failingEndpoint = require('./indicator/FailingEndpoint');
17-
app.use('/', failingEndpoint);
16+
app.use('/', require('./indicator/FailingEndpoint'));
17+
app.use('/', require('./indicator/HighLoadEndpoint'));
18+
app.use('/', require('./indicator/SlowEndpoint'));
19+
1820
app.listen(3000);
1921
}
2022

2123
startIndicators();
2224

2325
function executeIndicators() {
2426
const axios = require('axios');
27+
28+
//failing endpoint indicator
2529
axios.get('http://localhost:3000/indicator/fail-100-percent').catch(() => {});
2630
axios.get('http://localhost:3000/indicator/fail-75-percent').catch(() => {});
2731
axios.get('http://localhost:3000/indicator/fail-50-percent').catch(() => {});
32+
33+
//slow endpoint indicator
34+
axios.get('http://localhost:3000/indicator/slow-2000ms').catch(() => {});
35+
axios.get('http://localhost:3000/indicator/slow-1000ms').catch(() => {});
36+
37+
//high load endpoint indicator
38+
axios.get('http://localhost:3000/indicator/high-load-four-per-second').catch(() => {});
39+
axios.get('http://localhost:3000/indicator/high-load-four-per-second').catch(() => {});
40+
axios.get('http://localhost:3000/indicator/high-load-four-per-second').catch(() => {});
41+
axios.get('http://localhost:3000/indicator/high-load-four-per-second').catch(() => {});
42+
axios.get('http://localhost:3000/indicator/high-load-two-per-second').catch(() => {});
43+
axios.get('http://localhost:3000/indicator/high-load-two-per-second').catch(() => {});
2844
}
2945

3046
setInterval(executeIndicators, 1000);

0 commit comments

Comments
 (0)