Work on brewery page, refactors

Refactor query types to explicitly use z.infer
This commit is contained in:
Aaron William Po
2023-03-31 21:13:35 -04:00
parent d8a8dad37f
commit b69dbc95b4
33 changed files with 308 additions and 243 deletions

View File

@@ -1,36 +1,18 @@
import { z } from 'zod';
export const beerPostQueryResultSchema = z.object({
const beerPostQueryResult = z.object({
id: z.string(),
name: z.string(),
brewery: z.object({
id: z.string(),
name: z.string(),
}),
brewery: z.object({ id: z.string(), name: z.string() }),
description: z.string(),
beerImages: z.array(
z.object({
path: z.string(),
caption: z.string(),
id: z.string(),
alt: z.string(),
}),
z.object({ path: z.string(), caption: z.string(), id: z.string(), alt: z.string() }),
),
ibu: z.number(),
abv: z.number(),
type: z.object({
id: z.string(),
name: z.string(),
}),
postedBy: z.object({
id: z.string(),
username: z.string(),
}),
type: z.object({ id: z.string(), name: z.string() }),
postedBy: z.object({ id: z.string(), username: z.string() }),
createdAt: z.coerce.date(),
});
export const beerPostQueryResultArraySchema = z.array(beerPostQueryResultSchema);
export type BeerPostQueryResult = z.infer<typeof beerPostQueryResultSchema>;
export type BeerPostQueryResultArray = z.infer<typeof beerPostQueryResultArraySchema>;
export default beerPostQueryResult;