From a84ebc56e96d8e9abdbcd7685d3c1d062794df45 Mon Sep 17 00:00:00 2001 From: kaxada Date: Thu, 14 Dec 2023 03:41:33 +0300 Subject: [PATCH] added home route to confirm api status on ping --- .github/workflows/deploy.yml | 2 +- routes/index.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 98b3146..3b6d8d0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -57,4 +57,4 @@ jobs: --env-file /home/${{ secrets.USERNAME }}/.env \ --restart=always \ --name ${{ env.IMAGE_NAME }} \ - ${{ env.IMAGE_NAME }}:${{ github.sha }} \ No newline at end of file + ${{ env.IMAGE_NAME }}:${{ github.sha }} diff --git a/routes/index.js b/routes/index.js index 7351618..5e95a08 100644 --- a/routes/index.js +++ b/routes/index.js @@ -80,6 +80,31 @@ const badgedRepos = async (req, res) => { }; const setupRoutes = (app) => { + app.get("/api", (req, res) => { + try { + res.json({ message: "Project Badging server up and running" }); + } catch (error) { + console.error(error); + + if (error.statusCode && error.statusCode !== 200) { + res + .status(error.statusCode) + .json({ + error: "Error", + message: + "our bad, something is wrong with the server configuration", + }); + } else { + res + .status(500) + .json({ + error: "Internal Server Error", + message: "An unexpected error occurred at our end", + }); + } + } + }); + app.get("/api/auth/github", (req, res) => { githubAuth(req, res); });