Skip to content

Commit

Permalink
feat(api): allow passing id when creating category
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Jul 16, 2024
1 parent 7803df8 commit 838e0b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/api/v1/services/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ export async function createCategory({
user: User
data: CreateCategory
}) {
const { name, type, color, description, icon } = data
const { id, name, type, color, description, icon } = data

const category = await prisma.category.create({
data: {
id,
name,
type,
color,
Expand Down
1 change: 1 addition & 0 deletions packages/validation/src/category.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { z } from 'zod'
import { CategoryTypeSchema } from './prisma'

export const zCreateCategory = z.object({
id: z.string().cuid2().optional(),
type: CategoryTypeSchema,
name: z.string().min(1, {
message: 'Category name is required',
Expand Down

0 comments on commit 838e0b1

Please sign in to comment.