Skip to content

Commit

Permalink
Refactor status schema with zod
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucat0309 committed Nov 24, 2023
1 parent 6eaf555 commit 3b11af6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions api/schema/status.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Scenario } from './scenario'
import { AttendeeMetadata } from './attendee'
import { scenarioSchema } from './scenario'
import { attendeeMetadataSchema } from './attendee'
import { z } from 'zod'

export type Status = {
event_id: string
public_token: string
user_id: string
first_use: number | null
role: string
scenario: Record<string, Scenario>
attr: AttendeeMetadata
}
export type Status = z.infer<typeof statusSchema>
export const statusSchema = z.object({
event_id: z.string().default('COSCUP_2023'),
public_token: z.string().default('8b1619a7-347c-477a-9045-e48a7828a235'),
user_id: z.string().default('user1234'),
first_use: z.number().nullable().describe('timestamp').default(1650000000),
role: z.string().default('audience'),
scenario: z.record(scenarioSchema).describe('Scenario ID => Scenario'),
attr: attendeeMetadataSchema,
})

0 comments on commit 3b11af6

Please sign in to comment.