From 5d108a2781b83271ca6c74d81076894216fa582a Mon Sep 17 00:00:00 2001 From: limepotato Date: Mon, 16 Sep 2024 00:32:12 -0600 Subject: [PATCH] change status codes --- .../nelle/nelleObserverBackend/plugins/Routing.kt | 9 +++++++-- public/scripts/api.js | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/main/kotlin/observer/nelle/nelleObserverBackend/plugins/Routing.kt b/backend/src/main/kotlin/observer/nelle/nelleObserverBackend/plugins/Routing.kt index 74ccff0..4a553c7 100644 --- a/backend/src/main/kotlin/observer/nelle/nelleObserverBackend/plugins/Routing.kt +++ b/backend/src/main/kotlin/observer/nelle/nelleObserverBackend/plugins/Routing.kt @@ -34,10 +34,12 @@ fun Application.configureRouting(client: HttpClient) { // get meow timeout get("/meowTimeout") { if (meowTimedOut) { - call.response.status(HttpStatusCode(500, "FUCK")) + call.response.status(HttpStatusCode(423, "Timed Out")) + call.respondText("Timed Out") } if (!meowTimedOut) { - call.response.status(HttpStatusCode(200, "OKAY")) + call.response.status(HttpStatusCode(100, "Not Timed Out")) + call.respondText("Not Timed Out") } } @@ -45,13 +47,16 @@ fun Application.configureRouting(client: HttpClient) { @Suppress("ktlint:standard:comment-wrapping") post("/meow") { if (call.receiveText() == Config().superSecret) { + call.response.status(HttpStatusCode(201, "Meow Posted")) println("secret code received, bypassing timeout") makePost(client, getMeow(), Config().instanceDomain) println("meow sent!") } else { if (meowTimedOut) { + call.response.status(HttpStatusCode(423, "Timed Out")) call.respondText("still Sleeping...") } else { + call.response.status(HttpStatusCode(201, "Meow Posted")) makePost(client, getMeow(), Config().instanceDomain) meowTimer() call.respondText("meow sent!") diff --git a/public/scripts/api.js b/public/scripts/api.js index 060467a..9c508f0 100644 --- a/public/scripts/api.js +++ b/public/scripts/api.js @@ -14,12 +14,12 @@ function sendMeow(endpoint) { async function getMeowTimeout(endpoint) { const response = await fetch(endpoint) -if (response.status === 500) { +if (response.status === 423) { meowButton.disabled=true; meowButton.innerHTML = "sleeping..."; console.warn("TIMED OUT") } -if (response.status === 200) { +if (response.status === 100) { meowButton.disabled=false; meowButton.innerHTML = "meow"; console.warn("NOT TIMED OUT")