File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 5
5
"start" : " node src/main.js"
6
6
},
7
7
"dependencies" : {
8
- "sourceplusplus" : " ^0.0.8"
8
+ "sourceplusplus" : " ^0.0.8" ,
9
+ "express" : " 4.18.1"
9
10
}
10
11
}
Original file line number Diff line number Diff line change
1
+ const express = require ( 'express' ) ;
2
+ const router = express . Router ( ) ;
3
+
4
+ router . get ( '/fail-100-percent' , ( req , res ) => {
5
+ res . sendStatus ( 500 ) ;
6
+ } ) ;
7
+
8
+ router . get ( '/fail-75-percent' , ( req , res ) => {
9
+ if ( Math . random ( ) < 0.25 ) {
10
+ res . sendStatus ( 200 ) ;
11
+ } else {
12
+ res . sendStatus ( 500 ) ;
13
+ }
14
+ } ) ;
15
+
16
+ router . get ( '/fail-50-percent' , ( req , res ) => {
17
+ if ( Math . random ( ) > 0.5 ) {
18
+ res . sendStatus ( 500 ) ;
19
+ } else {
20
+ res . sendStatus ( 200 ) ;
21
+ }
22
+ } ) ;
23
+
24
+ module . exports = router ;
Original file line number Diff line number Diff line change @@ -8,3 +8,23 @@ function executeDemos() {
8
8
}
9
9
10
10
setInterval ( executeDemos , 1000 ) ;
11
+
12
+ function startIndicators ( ) {
13
+ const express = require ( 'express' ) ;
14
+
15
+ const app = express ( ) ;
16
+ const failingEndpoint = require ( './indicator/FailingEndpoint' ) ;
17
+ app . use ( '/indicator' , failingEndpoint ) ;
18
+ app . listen ( 3000 ) ;
19
+ }
20
+
21
+ startIndicators ( ) ;
22
+
23
+ function executeIndicators ( ) {
24
+ const axios = require ( 'axios' ) ;
25
+ axios . get ( 'http://localhost:3000/indicator/fail-100-percent' ) . catch ( ( ) => { } ) ;
26
+ axios . get ( 'http://localhost:3000/indicator/fail-75-percent' ) . catch ( ( ) => { } ) ;
27
+ axios . get ( 'http://localhost:3000/indicator/fail-50-percent' ) . catch ( ( ) => { } ) ;
28
+ }
29
+
30
+ setInterval ( executeIndicators , 1000 ) ;
You can’t perform that action at this time.
0 commit comments