Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
10 changes: 6 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -105,16 +105,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",
})
Expand Down