first commit 🎉

This commit is contained in:
2025-10-08 11:37:54 +07:00
commit 4ec61fa51e
61 changed files with 4558 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { z } from 'zod'
import { createSelectSchema, createInsertSchema } from 'drizzle-zod'
import { table as $t } from '~/db'
import { roleEnum } from '~/db/schema/users'
export const selectUserSchema = createSelectSchema($t.users)
export const $s = selectUserSchema.shape
export const $i = createInsertSchema($t.users).shape
export const roleSchema = createSelectSchema(roleEnum)
export const createUserBody = z.object({
name: $i.name.min(3),
email: $i.email,
phone: z.string().optional(),
password: z.string().min(8),
role: roleSchema.optional(), // will validate in service
partnerId: z.string().optional(),
})
export type CreateUserSchema = z.infer<typeof createUserBody>
export const createUserResponse = selectUserSchema.pick({
id: true,
name: true,
email: true,
phone: true,
role: true,
status: true,
createdAt: true,
})
export const listUserResponse = z.array(createUserResponse)
export type User = typeof $t.users.$inferSelect
export type NewUser = typeof $t.users.$inferInsert