Skip to content

Commit

Permalink
chore: add daily endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kan-A-Pesh committed Oct 29, 2024
1 parent 279c438 commit 51ba810
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format": "prettier --write .",
"lint": "eslint .",
"clear": "rm -rf dist node_modules coverage logs/*.log",
"clear:logs": "rm -rf logs/*.log",
"db:migrate": "drizzle-kit generate"
},
"author": {
Expand Down
3 changes: 3 additions & 0 deletions routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { Router } from "express";
import clubsRouter from "./routes/clubs/router";
import adminRouter from "./routes/admin/router";
import Route_Index_Read from "./routes/index";
import Route_Daily_Read from "./routes/daily";

const router = Router();

router.get("/", Route_Index_Read);
router.get("/daily", Route_Daily_Read);

router.use("/clubs", clubsRouter);
router.use("/admin", adminRouter);

Expand Down
19 changes: 19 additions & 0 deletions routes/daily.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ClubController from "@/controllers/clubs";
import Status from "@/models/status";
import { NextFunction, Request, Response } from "express";

export default async function Route_Daily_Read(req: Request, res: Response, next: NextFunction) {
const club = await ClubController.getDailyClub();

if (!club) {
return Status.send(req, next, {
status: 404,
error: "errors.notFound"
});
}

return Status.send(req, next, {
status: 200,
data: club
});
}
4 changes: 1 addition & 3 deletions tests/e2e/clubs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ describe("Test users", () => {
});

test("should get daily club", async () => {
const res = await get(app, "/daily", undefined, undefined, {
"X-ADMIN-KEY": globals.env.ADMIN_TOKEN
});
const res = await get(app, "/daily");

expect(res.body).toStrictEqual({
masterStatus: 200,
Expand Down

0 comments on commit 51ba810

Please sign in to comment.