Created
October 23, 2021 18:57
-
-
Save oleh-zaporozhets/05783a1bb30dfe4ec45aa921a4de1066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
let counter = 0; | |
app.get('/test', (_, res) => { | |
counter++; | |
console.log(`Incoming request №${counter}`); | |
let responseCode = 200; | |
if (counter % 3 === 0) { | |
responseCode = 400; | |
} | |
if (counter % 5 === 0) { | |
responseCode = 429; | |
} | |
return res.status(responseCode).send(); | |
}); | |
const PORT = 5000; | |
app.listen(PORT, () => { | |
console.log(`Server is ready on ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment