mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-06 02:19:05 +00:00
Update api routes and begin to extract controllers out of routing logic
This commit is contained in:
@@ -10,7 +10,7 @@ import { createRouter } from 'next-connect';
|
||||
import { z } from 'zod';
|
||||
import getCurrentUser from '@/config/nextConnect/middleware/getCurrentUser';
|
||||
import { NextApiResponse } from 'next';
|
||||
import CommentQueryResult from '@/services/schema/CommentSchema/CommentQueryResult';
|
||||
|
||||
import CreateCommentValidationSchema from '@/services/schema/CommentSchema/CreateCommentValidationSchema';
|
||||
|
||||
interface CreateCommentRequest extends UserExtendedNextApiRequest {
|
||||
@@ -30,7 +30,7 @@ const createComment = async (
|
||||
|
||||
const beerPostId = req.query.id;
|
||||
|
||||
const newBeerComment: z.infer<typeof CommentQueryResult> = await createNewBeerComment({
|
||||
const newBeerComment = await createNewBeerComment({
|
||||
content,
|
||||
rating,
|
||||
beerPostId,
|
||||
|
||||
@@ -20,8 +20,8 @@ interface EditBeerPostRequest extends BeerPostRequest {
|
||||
body: z.infer<typeof EditBeerPostValidationSchema>;
|
||||
}
|
||||
|
||||
const checkIfBeerPostOwner = async (
|
||||
req: BeerPostRequest,
|
||||
const checkIfBeerPostOwner = async <BeerPostRequestType extends BeerPostRequest>(
|
||||
req: BeerPostRequestType,
|
||||
res: NextApiResponse,
|
||||
next: NextHandler,
|
||||
) => {
|
||||
|
||||
Reference in New Issue
Block a user