mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-04-05 18:09:04 +00:00
Formatting changes
This commit is contained in:
@@ -13,13 +13,16 @@ import { NextApiResponse } from 'next';
|
||||
|
||||
interface CreateCommentRequest extends UserExtendedNextApiRequest {
|
||||
body: z.infer<typeof BeerCommentValidationSchema>;
|
||||
query: { id: string };
|
||||
}
|
||||
|
||||
const createComment = async (
|
||||
req: CreateCommentRequest,
|
||||
res: NextApiResponse<z.infer<typeof APIResponseValidationSchema>>,
|
||||
) => {
|
||||
const { content, rating, beerPostId } = req.body;
|
||||
const { content, rating } = req.body;
|
||||
|
||||
const beerPostId = req.query.id;
|
||||
|
||||
const newBeerComment: BeerCommentQueryResultT = await createNewBeerComment({
|
||||
content,
|
||||
@@ -42,7 +45,10 @@ const router = createRouter<
|
||||
>();
|
||||
|
||||
router.post(
|
||||
validateRequest({ bodySchema: BeerCommentValidationSchema }),
|
||||
validateRequest({
|
||||
bodySchema: BeerCommentValidationSchema,
|
||||
querySchema: z.object({ id: z.string().uuid() }),
|
||||
}),
|
||||
getCurrentUser,
|
||||
createComment,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import BeerForm from '@/components/BeerForm';
|
||||
import Layout from '@/components/ui/Layout';
|
||||
import withPageAuthRequired from '@/config/auth/withPageAuthRequired';
|
||||
|
||||
import DBClient from '@/prisma/DBClient';
|
||||
import getAllBreweryPosts from '@/services/BreweryPost/getAllBreweryPosts';
|
||||
@@ -30,7 +31,7 @@ const Create: NextPage<CreateBeerPageProps> = ({ breweries, types }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = async () => {
|
||||
export const getServerSideProps = withPageAuthRequired(async () => {
|
||||
const breweryPosts = await getAllBreweryPosts();
|
||||
const beerTypes = await DBClient.instance.beerType.findMany();
|
||||
|
||||
@@ -40,6 +41,6 @@ export const getServerSideProps = async () => {
|
||||
types: JSON.parse(JSON.stringify(beerTypes)),
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
export default Create;
|
||||
|
||||
Reference in New Issue
Block a user