mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 18:52:06 +00:00
Refactor and formatting
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import { z } from 'zod';
|
||||
import CreateCommentValidationSchema from '../schema/CommentSchema/CreateCommentValidationSchema';
|
||||
import BeerCommentQueryResult from './schema/BeerCommentQueryResult';
|
||||
|
||||
const CreateNewBeerCommentServiceSchema = CreateCommentValidationSchema.extend({
|
||||
userId: z.string().cuid(),
|
||||
beerPostId: z.string().cuid(),
|
||||
});
|
||||
|
||||
type CreateNewBeerCommentArgs = z.infer<typeof CreateNewBeerCommentServiceSchema>;
|
||||
|
||||
const createNewBeerComment = async ({
|
||||
content,
|
||||
rating,
|
||||
beerPostId,
|
||||
userId,
|
||||
}: z.infer<typeof CreateNewBeerCommentServiceSchema>) => {
|
||||
}: CreateNewBeerCommentArgs): Promise<z.infer<typeof BeerCommentQueryResult>> => {
|
||||
return DBClient.instance.beerComment.create({
|
||||
data: {
|
||||
content,
|
||||
@@ -26,6 +29,7 @@ const createNewBeerComment = async ({
|
||||
rating: true,
|
||||
postedBy: { select: { id: true, username: true } },
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user