feat: initial structure

This commit is contained in:
Sheen Capadngan
2024-08-15 14:49:30 +08:00
parent f4244c6d4d
commit f4384bb01e
13 changed files with 409 additions and 0 deletions
@@ -8,6 +8,7 @@ import {
PkiCollectionsSchema,
ProjectKeysSchema
} from "@app/db/schemas";
import { CertificateTemplatesSchema } from "@app/db/schemas/certificate-templates";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { PROJECTS } from "@app/lib/api-docs";
import { creationLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";
@@ -458,4 +459,39 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
return { collections: pkiCollections };
}
});
server.route({
method: "GET",
url: "/:projectId/certificate-templates",
config: {
rateLimit: readLimit
},
schema: {
params: z.object({
projectId: z.string().trim()
}),
response: {
200: z.object({
certificateTemplates: z.array(
CertificateTemplatesSchema.pick({
id: true,
name: true
})
)
})
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const { certificateTemplates } = await server.services.project.listProjectCertificateTemplates({
projectId: req.params.projectId,
actorId: req.permission.id,
actorOrgId: req.permission.orgId,
actorAuthMethod: req.permission.authMethod,
actor: req.permission.type
});
return { certificateTemplates };
}
});
};