From c6ec644831dfe4b787592084b671955e0eb50ead Mon Sep 17 00:00:00 2001 From: solvhold Date: Wed, 10 Sep 2025 17:09:27 +0200 Subject: [PATCH 1/2] feat: move selectTeamApplication from teams to applications VF-298 --- package.json | 2 +- src/response-handling/applications.ts | 9 ++---- src/routers/teams.ts | 45 --------------------------- 3 files changed, 3 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index b27f022..a0b44f5 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "db:migrate": "drizzle-kit migrate --config=db/config/drizzle.config.ts", "db:studio": "drizzle-kit studio --config=db/config/drizzle.config.ts", "db:seed": "tsx ./db/seeding/seeding.ts", - "docs:generate": "tsx ./src/openapi/generateDocument.ts" + "docs:generate": "tsx ./src/openapi/generate-document.ts" }, "license": "ISC", "dependencies": { diff --git a/src/response-handling/applications.ts b/src/response-handling/applications.ts index fa09a77..42df677 100644 --- a/src/response-handling/applications.ts +++ b/src/response-handling/applications.ts @@ -1,10 +1,7 @@ import { createSelectSchema } from "drizzle-zod"; import type { z } from "zod"; -import { - applicationsTable, - teamApplicationsTable, -} from "@/db/tables/applications"; +import { applicationsTable, teamApplicationsTable } from "@/db/tables/applications"; export const applicationSelectSchema = createSelectSchema(applicationsTable) .strict() @@ -13,9 +10,7 @@ export const applicationSelectSchema = createSelectSchema(applicationsTable) export type Application = z.infer; export type ApplicationKey = Application["id"]; -export const teamApplicationSelectSchema = createSelectSchema( - teamApplicationsTable, -) +export const teamApplicationSelectSchema = createSelectSchema(teamApplicationsTable) .merge(createSelectSchema(applicationsTable)) .strict() .readonly(); diff --git a/src/routers/teams.ts b/src/routers/teams.ts index 8dc58fa..7be0832 100644 --- a/src/routers/teams.ts +++ b/src/routers/teams.ts @@ -1,4 +1,3 @@ -import { selectTeamApplicationsByTeamId } from "@/src/db-access/applications"; import { selectTeamsById } from "@/src/db-access/teams"; import { clientError } from "@/src/error/http-errors"; import { @@ -10,50 +9,6 @@ import { Router, json } from "express"; export const teamsRouter = Router(); teamsRouter.use(json()); -/** - * @openapi - * /teams/{teamId}/applications/: - * get: - * tags: [teams] - * summary: Get teamapplication with teamid - * description: Get teamapplication with teamid - * parameters: - * - $ref: "#/components/parameters/offset" - * - $ref: "#/components/parameters/limit" - * responses: - * 200: - * description: Successfull response - * content: - * application/json: - * schema: - * $ref: "#/components/schemas/teamApplication" - */ -teamsRouter.get("/:teamId/applications/", async (req, res, next) => { - const teamIdResult = toSerialIdParser.safeParse(req.params.teamId); - if (!teamIdResult.success) { - return next(clientError(400, "Invalid request format", teamIdResult.error)); - } - const queryParametersResult = listQueryParser.safeParse(req.query); - if (!queryParametersResult.success) { - return next( - clientError(400, "Invalid request format", queryParametersResult.error), - ); - } - const databaseResult = await selectTeamApplicationsByTeamId( - [teamIdResult.data], - queryParametersResult.data, - ); - if (!databaseResult.success) { - return next( - clientError( - 400, - "Failed to execute the database command", - databaseResult.error, - ), - ); - } - res.json(databaseResult.data); -}); /** * @openapi From d567f3e9999e82ab50118f4424a39868dc97f12f Mon Sep 17 00:00:00 2001 From: solvhold Date: Wed, 10 Sep 2025 17:15:57 +0200 Subject: [PATCH 2/2] fix: run pnpm check VF-298 --- src/response-handling/applications.ts | 9 +++++++-- src/routers/teams.ts | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/response-handling/applications.ts b/src/response-handling/applications.ts index 42df677..fa09a77 100644 --- a/src/response-handling/applications.ts +++ b/src/response-handling/applications.ts @@ -1,7 +1,10 @@ import { createSelectSchema } from "drizzle-zod"; import type { z } from "zod"; -import { applicationsTable, teamApplicationsTable } from "@/db/tables/applications"; +import { + applicationsTable, + teamApplicationsTable, +} from "@/db/tables/applications"; export const applicationSelectSchema = createSelectSchema(applicationsTable) .strict() @@ -10,7 +13,9 @@ export const applicationSelectSchema = createSelectSchema(applicationsTable) export type Application = z.infer; export type ApplicationKey = Application["id"]; -export const teamApplicationSelectSchema = createSelectSchema(teamApplicationsTable) +export const teamApplicationSelectSchema = createSelectSchema( + teamApplicationsTable, +) .merge(createSelectSchema(applicationsTable)) .strict() .readonly(); diff --git a/src/routers/teams.ts b/src/routers/teams.ts index 7be0832..97e4a34 100644 --- a/src/routers/teams.ts +++ b/src/routers/teams.ts @@ -9,7 +9,6 @@ import { Router, json } from "express"; export const teamsRouter = Router(); teamsRouter.use(json()); - /** * @openapi * /teams/{teamId}/: