feat: admin slack configuration

This commit is contained in:
Sheen Capadngan
2024-09-04 23:06:30 +08:00
parent 71b8c59050
commit 956719f797
13 changed files with 465 additions and 15 deletions
@@ -123,6 +123,87 @@ export const registerAdminRouter = async (server: FastifyZodProvider) => {
}
});
server.route({
method: "GET",
url: "/integrations/slack/bot-creation-url",
config: {
rateLimit: readLimit
},
schema: {
response: {
200: z.string()
}
},
onRequest: (req, res, done) => {
verifyAuth([AuthMode.JWT])(req, res, () => {
verifySuperAdmin(req, res, done);
});
},
handler: async () => {
const url = await server.services.superAdmin.getCustomSlackBotCreationUrl();
return url;
}
});
server.route({
method: "GET",
url: "/integrations/slack/config",
config: {
rateLimit: readLimit
},
schema: {
response: {
200: z.object({
clientId: z.string(),
clientSecret: z.string()
})
}
},
onRequest: (req, res, done) => {
verifyAuth([AuthMode.JWT])(req, res, () => {
verifySuperAdmin(req, res, done);
});
},
handler: async () => {
const adminSlackConfig = await server.services.superAdmin.getAdminSlackConfig();
return adminSlackConfig;
}
});
server.route({
method: "PUT",
url: "/integrations/slack/config",
config: {
rateLimit: writeLimit
},
schema: {
body: z.object({
clientId: z.string(),
clientSecret: z.string()
}),
response: {
200: z.object({
clientId: z.string(),
clientSecret: z.string()
})
}
},
onRequest: (req, res, done) => {
verifyAuth([AuthMode.JWT])(req, res, () => {
verifySuperAdmin(req, res, done);
});
},
handler: async (req) => {
const adminSlackConfig = await server.services.superAdmin.updateAdminSlackConfig({
...req.body
});
return adminSlackConfig;
}
});
server.route({
method: "DELETE",
url: "/user-management/users/:userId",