From 219fab3df5885d9faaff0725901e8ecd94b8077f Mon Sep 17 00:00:00 2001 From: Timothy Gonzalez <105177619+Timothy-Gonzalez@users.noreply.github.com> Date: Fri, 19 Sep 2025 19:13:02 -0500 Subject: [PATCH] Add status for root --- src/app.test.ts | 8 +++++++- src/app.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app.test.ts b/src/app.test.ts index ff3d0caf..885fe59b 100644 --- a/src/app.test.ts +++ b/src/app.test.ts @@ -4,7 +4,13 @@ import { get } from "../testing/testingTools"; describe("general app test", () => { it("app should be running", async () => { - const response = await get("/status", undefined).expect(StatusCodes.OK); + let response = await get("/", undefined).expect(StatusCodes.OK); + expect(response.body).toMatchObject({ + ok: true, + message: "API is alive!", + }); + + response = await get("/status", undefined).expect(StatusCodes.OK); expect(response.body).toMatchObject({ ok: true, message: "API is alive!", diff --git a/src/app.ts b/src/app.ts index b581f7b5..230421ae 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import express from "express"; +import express, { Request, Response } from "express"; import { StatusCodes } from "http-status-codes"; import { Config, EnvironmentEnum } from "./config"; import { isTest } from "./utilities"; @@ -96,16 +96,18 @@ app.use("/speakers", speakersRouter); app.use("/meetings", meetingsRouter); app.use("/shifts", shiftsRouter); -app.get("/status", (req, res) => { +const status = (req: Request, res: Response) => { return res.status(StatusCodes.OK).send({ ok: true, message: "API is alive!", timestamp: new Date().toISOString(), environment: Config.ENV, }); -}); +}; +app.get("/status", status); +app.get("/", status); -app.use("/", (req, res) => +app.use((req, res) => res.status(StatusCodes.NOT_FOUND).send({ error: "EndpointNotFound", })