mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Refactor: force style consistency for pagination queries
All pagination queries now use an underscore for page_num, and page_size
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"arrowParens": "always",
|
||||
"bracketSpacing": false,
|
||||
"bracketSpacing": true,
|
||||
"jsxSingleQuote": false,
|
||||
"printWidth": 90,
|
||||
"proseWrap": "always",
|
||||
|
||||
@@ -38,7 +38,7 @@ const useBeerPosts = ({ pageSize }: { pageSize: number }) => {
|
||||
};
|
||||
|
||||
const { data, error, isLoading, setSize, size } = useSWRInfinite(
|
||||
(index) => `/api/beers?pageNum=${index + 1}&pageSize=${pageSize}`,
|
||||
(index) => `/api/beers?page_num=${index + 1}&page_size=${pageSize}`,
|
||||
fetcher,
|
||||
);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ const useBreweryPosts = ({ pageSize }: { pageSize: number }) => {
|
||||
};
|
||||
|
||||
const { data, error, isLoading, setSize, size } = useSWRInfinite(
|
||||
(index) => `/api/breweries?pageNum=${index + 1}&pageSize=${pageSize}`,
|
||||
(index) => `/api/breweries?page_num=${index + 1}&page_size=${pageSize}`,
|
||||
fetcher,
|
||||
);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import { z } from 'zod';
|
||||
|
||||
interface GetBeerPostsRequest extends NextApiRequest {
|
||||
query: {
|
||||
pageNum: string;
|
||||
pageSize: string;
|
||||
page_num: string;
|
||||
page_size: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ const getBeerPosts = async (
|
||||
req: GetBeerPostsRequest,
|
||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||
) => {
|
||||
const pageNum = parseInt(req.query.pageNum, 10);
|
||||
const pageSize = parseInt(req.query.pageSize, 10);
|
||||
const pageNum = parseInt(req.query.page_num, 10);
|
||||
const pageSize = parseInt(req.query.page_size, 10);
|
||||
|
||||
const beerPosts = await getAllBeerPosts(pageNum, pageSize);
|
||||
const beerPostCount = await DBClient.instance.beerPost.count();
|
||||
@@ -42,8 +42,8 @@ const router = createRouter<
|
||||
router.get(
|
||||
validateRequest({
|
||||
querySchema: z.object({
|
||||
pageNum: z.string().regex(/^\d+$/),
|
||||
pageSize: z.string().regex(/^\d+$/),
|
||||
page_num: z.string().regex(/^\d+$/),
|
||||
page_size: z.string().regex(/^\d+$/),
|
||||
}),
|
||||
}),
|
||||
getBeerPosts,
|
||||
|
||||
@@ -9,8 +9,8 @@ import { z } from 'zod';
|
||||
|
||||
interface GetBreweryPostsRequest extends NextApiRequest {
|
||||
query: {
|
||||
pageNum: string;
|
||||
pageSize: string;
|
||||
page_num: string;
|
||||
page_size: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ const getBreweryPosts = async (
|
||||
req: GetBreweryPostsRequest,
|
||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||
) => {
|
||||
const pageNum = parseInt(req.query.pageNum, 10);
|
||||
const pageSize = parseInt(req.query.pageSize, 10);
|
||||
const pageNum = parseInt(req.query.page_num, 10);
|
||||
const pageSize = parseInt(req.query.page_size, 10);
|
||||
|
||||
const breweryPosts = await getAllBreweryPosts(pageNum, pageSize);
|
||||
const breweryPostCount = await DBClient.instance.breweryPost.count();
|
||||
@@ -42,8 +42,8 @@ const router = createRouter<
|
||||
router.get(
|
||||
validateRequest({
|
||||
querySchema: z.object({
|
||||
pageNum: z.string().regex(/^\d+$/),
|
||||
pageSize: z.string().regex(/^\d+$/),
|
||||
page_num: z.string().regex(/^\d+$/),
|
||||
page_size: z.string().regex(/^\d+$/),
|
||||
}),
|
||||
}),
|
||||
getBreweryPosts,
|
||||
|
||||
Reference in New Issue
Block a user