feat: category and channel endpoints

This commit is contained in:
PrimarchPaul
2025-09-27 20:45:36 -04:00
parent 9b46852e20
commit d1273ca4ec
10 changed files with 1156 additions and 1 deletions

View File

@@ -0,0 +1,55 @@
import { z } from 'zod';
//category validators
export const createCategorySchema = z.object({
name: z.string().min(1).max(50),
position: z.number().min(0),
instanceId : z.uuidv7().optional(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const getCategorySchema = z.object({
id: z.uuidv7()
})
export const getCategoriesByInstanceIdSchema = z.object({
instanceId: z.uuidv7()
})
export const updateCategorySchema = z.object({
id: z.uuidv7(),
name: z.string().min(1).max(50).optional(),
position: z.number().min(0).optional(),
channels: z.array(z.object({
id: z.string()
})).optional(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const deleteCategorySchema = z.object({
id: z.uuidv7(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const deleteCategoriesByInstanceIdSchema = z.object({
instanceId: z.uuidv7(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export type CreateCategoryInput = z.infer<typeof createCategorySchema>
export type GetCategoryInput = z.infer<typeof getCategorySchema>
export type GetCategoriesByInstanceIdInput = z.infer<typeof getCategoriesByInstanceIdSchema>
export type UpdateCategoryInput = z.infer<typeof updateCategorySchema>
export type DeleteCategoryInput = z.infer<typeof deleteCategorySchema>
export type DeleteCategoriesByInstanceIdInput = z.infer<typeof deleteCategoriesByInstanceIdSchema>

View File

@@ -0,0 +1,52 @@
import { z } from "zod";
//channel validators
export const createChannelSchema = z.object({
type: z.enum(['text', 'voice']),
name: z.string().min(1).max(50),
description: z.string().max(255),
categoryId: z.uuidv7().optional(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const getChannelSchema = z.object({
id: z.uuidv7()
})
export const getChannelsByCategoryIdSchema = z.object({
categoryId: z.uuidv7()
})
export const updateChannelSchema = z.object({
id: z.uuidv7(),
name: z.string().min(1).max(50).optional(),
description: z.string().max(255).optional(),
categoryId: z.uuidv7().optional(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const deleteChannelSchema = z.object({
id: z.uuidv7(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export const deleteChannelsByCategoryIdSchema = z.object({
categoryId: z.uuidv7(),
admin: z.boolean(),
requestingUserId: z.uuidv7(),
requestingUserToken: z.uuidv4()
})
export type CreateChannelInput = z.infer<typeof createChannelSchema>
export type GetChannelInput = z.infer<typeof getChannelSchema>
export type GetChannelsByCategoryIdInput = z.infer<typeof getChannelsByCategoryIdSchema>
export type UpdateChannelInput = z.infer<typeof updateChannelSchema>
export type DeleteChannelInput = z.infer<typeof deleteChannelSchema>
export type DeleteChannelsByCategoryIdInput = z.infer<typeof deleteChannelsByCategoryIdSchema>

View File

@@ -7,7 +7,7 @@ export const queryUserByIdSchema = z.object({
export const queryAllUsersByInstanceId = z.object({
instanceId: z.uuidv7(),
});
import { is } from 'zod/v4/locales';
export const createUserSchema = z.object({
username: z.string().min(3).max(30),
nickname: z.string().min(1).max(30).optional(),