Update github form ui add scope and init org api

This commit is contained in:
Salman
2024-02-14 04:21:50 +05:30
parent c8cfb43316
commit df459d456a
7 changed files with 325 additions and 88 deletions
@@ -343,6 +343,38 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
}
});
server.route({
url: "/:integrationAuthId/github/orgs",
method: "GET",
onRequest: verifyAuth([AuthMode.JWT]),
schema: {
params: z.object({
integrationAuthId: z.string().trim()
}),
response: {
200: z.object({
orgs: z.object({ name: z.string(), orgId: z.string() }).array()
})
}
},
handler: async (req) => {
try {
const orgs = await server.services.integrationAuth.getGithubOrgs({
actorId: req.permission.id,
actor: req.permission.type,
actorOrgId: req.permission.orgId,
id: req.params.integrationAuthId
});
if (!orgs) throw new Error("No organization found.");
return { orgs: orgs || [] };
} catch (e) {
console.error(e);
return { orgs: [] };
}
}
});
server.route({
url: "/:integrationAuthId/qovery/orgs",
method: "GET",