From f180b5ed6a62845699c201d3e6ec66e9e72ad7e2 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:11:32 +0400 Subject: [PATCH] Route --- .../server/routes/v2/organization-router.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/backend/src/server/routes/v2/organization-router.ts b/backend/src/server/routes/v2/organization-router.ts index ed4a894c5..d2fa7d450 100644 --- a/backend/src/server/routes/v2/organization-router.ts +++ b/backend/src/server/routes/v2/organization-router.ts @@ -46,6 +46,42 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => { } }); + server.route({ + method: "GET", + url: "/:organizationId/workspaces", + schema: { + params: z.object({ + organizationId: z.string().trim() + }), + response: { + 200: z.object({ + workspaces: z + .object({ + name: z.string(), + organization: z.string(), + environments: z + .object({ + name: z.string(), + slug: z.string() + }) + .array() + }) + .array() + }) + } + }, + onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.IDENTITY_ACCESS_TOKEN]), + handler: async (req) => { + const workspaces = await server.services.org.findAllWorkspaces({ + actor: req.permission.type, + actorId: req.permission.id, + orgId: req.params.organizationId + }); + + return { workspaces }; + } + }); + server.route({ method: "PATCH", url: "/:organizationId/memberships/:membershipId",