improvement: address requested feedback

This commit is contained in:
Scott Wilson
2024-11-07 12:38:33 -08:00
parent 61f786e8d8
commit 19c26c680c
24 changed files with 263 additions and 193 deletions
+12 -4
View File
@@ -9,6 +9,7 @@ import {
ProjectKeysSchema
} from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { InfisicalProjectTemplate } from "@app/ee/services/project-template/project-template-types";
import { PROJECTS } from "@app/lib/api-docs";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
@@ -170,7 +171,14 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
.optional()
.describe(PROJECTS.CREATE.slug),
kmsKeyId: z.string().optional(),
templateId: z.string().uuid().optional().describe(PROJECTS.CREATE.templateId)
template: z
.string()
.refine((v) => slugify(v) === v, {
message: "Template name must be in slug format"
})
.optional()
.default(InfisicalProjectTemplate.Default)
.describe(PROJECTS.CREATE.template)
}),
response: {
200: z.object({
@@ -188,7 +196,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
workspaceName: req.body.projectName,
slug: req.body.slug,
kmsKeyId: req.body.kmsKeyId,
templateId: req.body.templateId
template: req.body.template
});
await server.services.telemetry.sendPostHogEvents({
@@ -201,14 +209,14 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
}
});
if (req.body.templateId) {
if (req.body.template) {
await server.services.auditLog.createAuditLog({
...req.auditLogInfo,
orgId: req.permission.orgId,
event: {
type: EventType.APPLY_PROJECT_TEMPLATE,
metadata: {
templateId: req.body.templateId,
template: req.body.template,
projectId: project.id
}
}