mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
fix update-avatar
This commit is contained in:
25
src/pages/api/users/[id]/profile/update-profile.ts
Normal file
25
src/pages/api/users/[id]/profile/update-profile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import getCurrentUser from '@/config/nextConnect/middleware/getCurrentUser';
|
||||
import validateRequest from '@/config/nextConnect/middleware/validateRequest';
|
||||
import { checkIfUserCanUpdateProfile, updateProfile } from '@/controllers/users/profile';
|
||||
import { UpdateProfileRequest } from '@/controllers/users/profile/types';
|
||||
|
||||
import APIResponseValidationSchema from '@/validation/APIResponseValidationSchema';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { createRouter } from 'next-connect';
|
||||
import { z } from 'zod';
|
||||
|
||||
const router = createRouter<
|
||||
UpdateProfileRequest,
|
||||
NextApiResponse<z.infer<typeof APIResponseValidationSchema>>
|
||||
>();
|
||||
|
||||
router.put(
|
||||
getCurrentUser,
|
||||
checkIfUserCanUpdateProfile,
|
||||
validateRequest({ bodySchema: z.object({ bio: z.string().max(1000) }) }),
|
||||
updateProfile,
|
||||
);
|
||||
|
||||
const handler = router.handler();
|
||||
|
||||
export default handler;
|
||||
Reference in New Issue
Block a user