mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Refactor: rename [:id] to [:postId] for api routes
This commit is contained in:
@@ -28,9 +28,9 @@ export const checkIfBeerPostOwner = async <BeerPostRequestType extends BeerPostR
|
||||
next: NextHandler,
|
||||
) => {
|
||||
const { user, query } = req;
|
||||
const { id } = query;
|
||||
const { postId } = query;
|
||||
|
||||
const beerPost = await getBeerPostById({ beerPostId: id });
|
||||
const beerPost = await getBeerPostById({ beerPostId: postId });
|
||||
|
||||
if (!beerPost) {
|
||||
throw new ServerError('Beer post not found', 404);
|
||||
@@ -47,7 +47,7 @@ export const editBeerPost = async (
|
||||
req: EditBeerPostRequest,
|
||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||
) => {
|
||||
await editBeerPostByIdService({ beerPostId: req.query.id, body: req.body });
|
||||
await editBeerPostByIdService({ beerPostId: req.query.postId, body: req.body });
|
||||
|
||||
res.status(200).json({
|
||||
message: 'Beer post updated successfully',
|
||||
@@ -57,9 +57,9 @@ export const editBeerPost = async (
|
||||
};
|
||||
|
||||
export const deleteBeerPost = async (req: BeerPostRequest, res: NextApiResponse) => {
|
||||
const { id } = req.query;
|
||||
const { postId } = req.query;
|
||||
|
||||
const deleted = await deleteBeerPostByIdService({ beerPostId: id });
|
||||
const deleted = await deleteBeerPostByIdService({ beerPostId: postId });
|
||||
if (!deleted) {
|
||||
throw new ServerError('Beer post not found', 404);
|
||||
}
|
||||
@@ -75,9 +75,9 @@ export const getBeerPostRecommendations = async (
|
||||
req: GetBeerRecommendationsRequest,
|
||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||
) => {
|
||||
const { id } = req.query;
|
||||
const { postId } = req.query;
|
||||
|
||||
const beerPost = await getBeerPostById({ beerPostId: id });
|
||||
const beerPost = await getBeerPostById({ beerPostId: postId });
|
||||
|
||||
if (!beerPost) {
|
||||
throw new ServerError('Beer post not found', 404);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { NextApiRequest } from 'next';
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface BeerPostRequest extends UserExtendedNextApiRequest {
|
||||
query: { id: string };
|
||||
query: { postId: string };
|
||||
}
|
||||
|
||||
export interface EditBeerPostRequest extends BeerPostRequest {
|
||||
@@ -17,7 +17,7 @@ export interface GetAllBeerPostsRequest extends NextApiRequest {
|
||||
}
|
||||
|
||||
export interface GetBeerRecommendationsRequest extends BeerPostRequest {
|
||||
query: { id: string; page_num: string; page_size: string };
|
||||
query: { postId: string; page_num: string; page_size: string };
|
||||
}
|
||||
|
||||
export interface CreateBeerPostRequest extends UserExtendedNextApiRequest {
|
||||
|
||||
Reference in New Issue
Block a user