mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Refactor: begin reorganizing services dir.
- Renamed files and directories to reflect the new structure - Moved comment-related services to the 'comments' directory - Moved image-related services to the 'images' directory - Moved like-related services to the 'likes' directory - Moved post-related services to the 'posts' directory - Moved user-related services to the 'users' directory
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import { z } from 'zod';
|
||||
import CreateCommentValidationSchema from '../../schema/CommentSchema/CreateCommentValidationSchema';
|
||||
import CommentQueryResult from '../../schema/CommentSchema/CommentQueryResult';
|
||||
|
||||
const CreateNewBeerStyleCommentServiceSchema = CreateCommentValidationSchema.extend({
|
||||
userId: z.string().cuid(),
|
||||
beerStyleId: z.string().cuid(),
|
||||
});
|
||||
|
||||
type CreateNewBeerCommentArgs = z.infer<typeof CreateNewBeerStyleCommentServiceSchema>;
|
||||
|
||||
const createNewBeerStyleComment = async ({
|
||||
content,
|
||||
rating,
|
||||
userId,
|
||||
beerStyleId,
|
||||
}: CreateNewBeerCommentArgs): Promise<z.infer<typeof CommentQueryResult>> => {
|
||||
return DBClient.instance.beerStyleComment.create({
|
||||
data: {
|
||||
content,
|
||||
rating,
|
||||
beerStyle: { connect: { id: beerStyleId } },
|
||||
postedBy: { connect: { id: userId } },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
content: true,
|
||||
rating: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
postedBy: {
|
||||
select: { id: true, username: true, createdAt: true, userAvatar: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default createNewBeerStyleComment;
|
||||
Reference in New Issue
Block a user