From c2dc9a7bf5ebcb7c3dae6aed7bbe64d3a968e671 Mon Sep 17 00:00:00 2001 From: Jesse Pence Date: Mon, 23 Oct 2023 01:43:49 -0700 Subject: [PATCH] documentation is hard --- server2.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 server2.js diff --git a/server2.js b/server2.js deleted file mode 100644 index 47c7596..0000000 --- a/server2.js +++ /dev/null @@ -1,37 +0,0 @@ -import express from "express" - -const app = express() -const PORT = 3000 - -let requestCounter = 0 - -app.use(express.static("tests")) - -let firstRequestTime = null - -app.get("/data", (req, res) => { - requestCounter++ - - // note the time at which the request was made - firstRequestTime = firstRequestTime || new Date() - console.log( - `Request #${requestCounter} received at ${new Date().toLocaleTimeString()}, first request at ${firstRequestTime.toLocaleTimeString()}` - ) - - // Mock an error for the first 5 requests - if (requestCounter <= 5) { - res.status(500).send("Something went wrong!") - } else { - // note the difference in the response time - const responseTime = new Date() - res.send( - `Request #${requestCounter} took ${ - Number(responseTime) - Number(firstRequestTime) - } milliseconds` - ) - } -}) - -app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`) -})