refactor: update board slug prefix to use dynamic base URL from env (#38)
* refactor: update board slug prefix to use dynamic base URL from env * feat: add board slug availability check with real-time validation UI * refactor: consolidate board slug lookup by removing boardSlug repo and updating environment variables * feat: allow board slug reuse across different workspaces * chore: update environment settings and remove unused imports * refactor: update board slug availability check to use boardPublicId instead of workspaceSlug * refactor: simplify board slug availability check with direct SQL query
This commit is contained in:
@@ -352,4 +352,40 @@ export const boardRouter = createTRPCRouter({
|
||||
|
||||
return { success: true };
|
||||
}),
|
||||
checkSlugAvailability: publicProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
summary: "Check if a board slug is available",
|
||||
method: "GET",
|
||||
path: "/boards/{boardPublicId}/check-slug-availability",
|
||||
description: "Checks if a board slug is available",
|
||||
tags: ["Boards"],
|
||||
protect: true,
|
||||
},
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
boardSlug: z
|
||||
.string()
|
||||
.min(3)
|
||||
.max(24)
|
||||
.regex(/^(?![-]+$)[a-zA-Z0-9-]+$/),
|
||||
boardPublicId: z.string().min(12),
|
||||
}),
|
||||
)
|
||||
.output(
|
||||
z.object({
|
||||
isReserved: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const isBoardSlugAvailable = await boardRepo.isBoardSlugAvailable(
|
||||
ctx.db,
|
||||
input.boardSlug,
|
||||
input.boardPublicId,
|
||||
);
|
||||
return {
|
||||
isReserved: !isBoardSlugAvailable,
|
||||
};
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user