Skip to content

Commit

Permalink
add api endpoint to retrieve project id by project name
Browse files Browse the repository at this point in the history
  • Loading branch information
guptave2 committed Nov 10, 2024
1 parent 7db0bd7 commit 197d002
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions backend/src/server/routes/v2/project-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,39 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
return { certificateTemplates };
}
});

/* Get a project ID by slug */
server.route({
method: "GET",
url: "/:slug/id",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
slug: slugSchema.describe("The slug of the project to get the ID for.")
}),
response: {
200: z.object({
id: z.string().describe("The ID of the project.")
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const project = await server.services.project.getAProject({
filter: {
slug: req.params.slug,
orgId: req.permission.orgId,
type: ProjectFilterType.SLUG
},
actorId: req.permission.id,
actorOrgId: req.permission.orgId,
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type
});

return { id: project.id };
}
});
};

0 comments on commit 197d002

Please sign in to comment.