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,26 +1,21 @@
import DBClient from '@/prisma/DBClient';
import BreweryPostQueryResult from './types/BreweryPostQueryResult';
import BreweryPostQueryResult from '@/services/BreweryPost/types/BreweryPostQueryResult';
import { z } from 'zod';
const prisma = DBClient.instance;
const getBreweryPostById = async (id: string) => {
const breweryPost: BreweryPostQueryResult | null = await prisma.breweryPost.findFirst({
select: {
id: true,
location: true,
name: true,
postedBy: {
select: {
firstName: true,
lastName: true,
id: true,
},
const breweryPost: z.infer<typeof BreweryPostQueryResult> | null =
await prisma.breweryPost.findFirst({
select: {
id: true,
location: true,
name: true,
breweryImages: { select: { path: true, caption: true, id: true, alt: true } },
postedBy: { select: { username: true, id: true } },
},
},
where: {
id,
},
});
where: { id },
});
return breweryPost;
};