Restructure codebase to use src directory

This commit is contained in:
Aaron William Po
2023-04-11 23:32:06 -04:00
parent 90f2cc2c0c
commit 08422fe24e
141 changed files with 6 additions and 4 deletions

View File

@@ -0,0 +1,32 @@
import DBClient from '@/prisma/DBClient';
import beerPostQueryResult from '@/services/BeerPost/schema/BeerPostQueryResult';
import { z } from 'zod';
const prisma = DBClient.instance;
const getAllBeerPosts = async (pageNum: number, pageSize: number) => {
const skip = (pageNum - 1) * pageSize;
const beerPosts: z.infer<typeof beerPostQueryResult>[] = await prisma.beerPost.findMany(
{
select: {
id: true,
name: true,
ibu: true,
abv: true,
description: true,
createdAt: true,
type: { select: { name: true, id: true } },
brewery: { select: { name: true, id: true } },
postedBy: { select: { id: true, username: true } },
beerImages: { select: { path: true, caption: true, id: true, alt: true } },
},
take: pageSize,
skip,
},
);
return beerPosts;
};
export default getAllBeerPosts;