feat(api): implement /api/user/me endpoint

This commit is contained in:
Dominik 2025-06-20 13:28:33 +02:00
parent 87dc6162f4
commit 3e890d4363
Signed by: dominik
GPG key ID: 06A4003FC5049644
5 changed files with 439 additions and 0 deletions

View file

@ -0,0 +1,63 @@
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
import { FullUserResponseSchema } from '../validation';
import { updateUserServerSchema } from './validation';
import {
invalidRequestDataResponse,
notAuthenticatedResponse,
serverReturnedDataValidationErrorResponse,
userNotFoundResponse,
} from '@/lib/defaultApiResponses';
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
registry.registerPath({
method: 'get',
path: '/api/user/me',
description: 'Get the currently authenticated user',
responses: {
200: {
description: 'User information retrieved successfully',
content: {
'application/json': {
schema: FullUserResponseSchema,
},
},
},
...notAuthenticatedResponse,
...userNotFoundResponse,
...serverReturnedDataValidationErrorResponse,
},
tags: ['User'],
});
registry.registerPath({
method: 'patch',
path: '/api/user/me',
description: 'Update the currently authenticated user',
request: {
body: {
description: 'User information to update',
required: true,
content: {
'application/json': {
schema: updateUserServerSchema,
},
},
},
},
responses: {
200: {
description: 'User information updated successfully',
content: {
'application/json': {
schema: FullUserResponseSchema,
},
},
},
...invalidRequestDataResponse,
...notAuthenticatedResponse,
...userNotFoundResponse,
...serverReturnedDataValidationErrorResponse,
},
tags: ['User'],
});
}