diff --git a/src/documentation/Educational-StageDescribers.ts b/src/documentation/Educational-StageDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..a476d4183ff6876250bd98209114e1914249bddc --- /dev/null +++ b/src/documentation/Educational-StageDescribers.ts @@ -0,0 +1,293 @@ +import { describeRoute } from 'hono-openapi' + +// Descrição da rota POST /create +const createEducationalStageRoute = describeRoute({ + method: 'POST', + path: '/create', + tags: ['Educational-Stage'], + summary: 'Create a new educational stage', + requestBody: { + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + name: { type: 'string', description: 'Name of the educational stage' }, + description: { type: 'string', description: 'Description of the educational stage' }, + }, + required: ['name'], + }, + }, + }, + }, + responses: { + 200: { + description: 'Educational stage created successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + educationalStage: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the created educational stage' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request due to invalid input', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, +}) + +// Descrição da rota POST /update + const updateEducationalStageRoute = describeRoute({ + method: 'POST', + path: '/update', + tags: ['Educational-Stage'], + summary: 'Update an existing educational stage', + requestBody: { + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the educational stage to update' }, + name: { type: 'string', description: 'Updated name of the educational stage' }, + description: { type: 'string', description: 'Updated description of the educational stage' }, + }, + required: ['id'], + }, + }, + }, + }, + responses: { + 200: { + description: 'Educational stage updated successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + educationalStage: { + type: 'object', + properties: { + id: { type: 'integer' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request due to invalid input', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, +}) + +// Descrição da rota POST /delete/:id + const deleteEducationalStageRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + tags: ['Educational-Stage'], + summary: 'Delete an educational stage by ID', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the educational stage to delete', + }, + }, + ], + responses: { + 200: { + description: 'Educational stage deleted successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + educationalStage: { + type: 'object', + properties: { + id: { type: 'integer' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request due to invalid ID', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, +}) + +// Descrição da rota GET /all + const getAllEducationalStagesRoute = describeRoute({ + method: 'GET', + path: '/all', + tags: ['Educational-Stage'], + summary: 'Get all educational stages', + responses: { + 200: { + description: 'List of educational stages retrieved successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + educationalStages: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, +}) + +// Descrição da rota GET /:id + const getEducationalStageByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + tags: ['Educational-Stage'], + summary: 'Get an educational stage by ID', + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the educational stage to retrieve', + }, + }, + ], + responses: { + 200: { + description: 'Educational stage retrieved successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + educationalStage: { + type: 'object', + properties: { + id: { type: 'integer' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request due to invalid ID', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, +}) + +export { + createEducationalStageRoute, + updateEducationalStageRoute, + deleteEducationalStageRoute, + getAllEducationalStagesRoute, + getEducationalStageByIdRoute, +} diff --git a/src/documentation/ItemDescriber.ts b/src/documentation/ItemDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..48422bdbc9e210ac0a1fc1b9e0bb893e5b681b85 --- /dev/null +++ b/src/documentation/ItemDescriber.ts @@ -0,0 +1,337 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createItemRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new item.', + tags: ['Item'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + required: ['name', 'description', 'price', 'quantity'], + }, + }, + }, + responses: { + 200: { + description: 'Item created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + item: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateItemRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing item.', + tags: ['Item'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + required: ['id', 'name', 'description', 'price', 'quantity'], + }, + }, + }, + responses: { + 200: { + description: 'Item updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + item: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteItemRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete an item by ID.', + tags: ['Item'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Item deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + item: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /active/:id + const activeItemRoute = describeRoute({ + method: 'POST', + path: '/active/{id}', + description: 'Activate an item by ID.', + tags: ['Item'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Item activated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + item: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all (public route) + const getAllItemsRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get a list of all items.', + tags: ['Item'], + responses: { + 200: { + description: 'List of items.', + content: { + 'application/json': { + type: 'object', + properties: { + items: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find items.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id (public route) + const getItemByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get an item by ID.', + tags: ['Item'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Item found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + item: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + price: { type: 'number' }, + quantity: { type: 'number' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find item.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createItemRoute, + updateItemRoute, + deleteItemRoute, + activeItemRoute, + getAllItemsRoute, + getItemByIdRoute +} \ No newline at end of file diff --git a/src/documentation/collectionsDescribers.ts b/src/documentation/collectionsDescribers.ts index 35043fe6127fa16f69f2e47e780fe1e069b906be..81f5037a57039075986681eae34353fdea0deb7b 100644 --- a/src/documentation/collectionsDescribers.ts +++ b/src/documentation/collectionsDescribers.ts @@ -3,6 +3,7 @@ const createCollectionRoute = describeRoute({ method: 'POST', path: '/create', description: 'Creates a new collection, which includes generating associated statistics.', + tags: ['Collections'], request: { body: { collection_stats_id: { @@ -76,6 +77,7 @@ const updateCollectionRoute = describeRoute({ method: 'POST', path: '/update', description: 'Updates an existing collection.', + tags: ['Collections'], request: { body: { id: { @@ -133,6 +135,7 @@ const deleteCollectionRoute = describeRoute({ method: 'POST', path: '/delete/:id', description: 'Deletes a collection by ID.', + tags: ['Collections'], request: { params: { id: { @@ -170,6 +173,7 @@ const deletePermanentlyCollectionRoute = describeRoute({ method: 'POST', path: '/delete-permanently/:id', description: 'Permanently deletes a collection by ID.', + tags: ['Collections'], request: { params: { id: { @@ -207,6 +211,7 @@ const restoreCollectionRoute = describeRoute({ method: 'POST', path: '/restore/:id', description: 'Restores a deleted collection by ID.', + tags: ['Collections'], request: { params: { id: { diff --git a/src/documentation/comment-replyDescribers.ts b/src/documentation/comment-replyDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0ce3c80bfac29f5937b1ad98c974fa5f4c5bdbd --- /dev/null +++ b/src/documentation/comment-replyDescribers.ts @@ -0,0 +1,390 @@ +import { describeRoute } from 'hono-openapi'; + +// POST /create +const createCommentReplyRouteDescription = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new reply for a comment.', + tags: ['Comment-Reply'], + requestBody: { + description: 'JSON object representing the reply to a comment.', + required: true, + schema: { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user posting the reply' }, + comment_id: { type: 'integer', description: 'ID of the comment being replied to' }, + content: { type: 'string', description: 'Content of the reply' } + }, + required: ['user_id', 'comment_id', 'content'] + } + }, + responses: { + 200: { + description: 'Reply comment created successfully.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the reply comment' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + comment_id: { type: 'integer', description: 'ID of the comment' }, + content: { type: 'string', description: 'Content of the reply' }, + created_at: { type: 'string', format: 'date-time', description: 'Date and time the reply was created' }, + updated_at: { type: 'string', format: 'date-time', description: 'Date and time the reply was last updated' } + } + } + } + } + }, + 400: { + description: 'Error in creating the reply comment, invalid input.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error', description: 'Status of the operation' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400, description: 'HTTP status code' }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +// POST /update +const updateCommentReplyRouteDescription = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing reply to a comment.', + tags: ['Comment-Reply'], + requestBody: { + description: 'JSON object representing the updated reply to a comment.', + required: true, + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the reply to be updated' }, + user_id: { type: 'integer', description: 'ID of the user posting the updated reply' }, + content: { type: 'string', description: 'Updated content of the reply' } + }, + required: ['id', 'user_id', 'content'] + } + }, + responses: { + 200: { + description: 'Reply comment updated successfully.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the updated reply comment' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + content: { type: 'string', description: 'Updated content of the reply' }, + updated_at: { type: 'string', format: 'date-time', description: 'Date and time the reply was last updated' } + } + } + } + } + }, + 400: { + description: 'Error in updating the reply comment, invalid input.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error', description: 'Status of the operation' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400, description: 'HTTP status code' }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +// POST /deleteData/:id +const deleteDataCommentReplyRouteDescription = describeRoute({ + method: 'POST', + path: '/deleteData/:id', + description: 'Delete a reply comment based on its ID.', + tags: ['Comment-Reply'], + parameters: [ + { + name: 'id', + in: 'path', + description: 'ID of the reply to delete', + required: true, + schema: { type: 'integer' } + } + ], + responses: { + 200: { + description: 'Reply comment deleted successfully.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the deleted reply comment' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + content: { type: 'string', description: 'Content of the reply' }, + deleted_at: { type: 'string', format: 'date-time', description: 'Date and time the reply was deleted' } + } + } + } + } + }, + 400: { + description: 'Error in deleting the reply comment, invalid ID.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error', description: 'Status of the operation' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400, description: 'HTTP status code' }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +// POST /delete/:id +const deleteCommentReplyRouteDescription = describeRoute({ + method: 'POST', + path: '/delete/:id', + description: 'Delete a reply comment based on its ID.', + tags: ['Comment-Reply'], + parameters: [ + { + name: 'id', + in: 'path', + description: 'ID of the reply to delete', + required: true, + schema: { type: 'integer' } + } + ], + responses: { + 200: { + description: 'Reply comment deleted successfully.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the deleted reply comment' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + content: { type: 'string', description: 'Content of the reply' }, + deleted_at: { type: 'string', format: 'date-time', description: 'Date and time the reply was deleted' } + } + } + } + } + }, + 400: { + description: 'Error in deleting the reply comment, invalid ID.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error', description: 'Status of the operation' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400, description: 'HTTP status code' }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +const findReplyByCommentRouteDescription = describeRoute({ + method: 'GET', + path: '/findReplyByComment/:comment_id', + description: 'Get active reply for a specific comment by comment ID.', + tags: ['Comment-Reply'], + parameters: [ + { + name: 'comment_id', + in: 'path', + description: 'ID of the comment to find active replies for', + required: true, + schema: { type: 'integer' } + } + ], + responses: { + 200: { + description: 'Active reply found for the comment.', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the reply' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + comment_id: { type: 'integer', description: 'ID of the comment' }, + content: { type: 'string', description: 'Content of the reply' }, + created_at: { type: 'string', format: 'date-time', description: 'Date the reply was created' } + } + } + } + } + } + }, + 400: { + description: 'Error finding active reply, invalid comment ID.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400 }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +// GET /findAllReplyByComment/:comment_id +const findAllReplyByCommentRouteDescription = describeRoute({ + method: 'GET', + path: '/findAllReplyByComment/:comment_id', + description: 'Get all replies for a specific comment by comment ID.', + tags: ['Comment-Reply'], + parameters: [ + { + name: 'comment_id', + in: 'path', + description: 'ID of the comment to find all replies for', + required: true, + schema: { type: 'integer' } + } + ], + responses: { + 200: { + description: 'All replies found for the comment.', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the reply' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + comment_id: { type: 'integer', description: 'ID of the comment' }, + content: { type: 'string', description: 'Content of the reply' }, + created_at: { type: 'string', format: 'date-time', description: 'Date the reply was created' } + } + } + } + } + } + }, + 400: { + description: 'Error finding replies, invalid comment ID.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400 }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +// GET /findAllReplyByUser/:id_user +const findAllReplyByUserRouteDescription = describeRoute({ + method: 'GET', + path: '/findAllReplyByUser/:id_user', + description: 'Get all replies by a specific user based on user ID.', + tags: ['Comment-Reply'], + parameters: [ + { + name: 'id_user', + in: 'path', + description: 'ID of the user to find all replies for', + required: true, + schema: { type: 'integer' } + } + ], + responses: { + 200: { + description: 'All replies found for the user.', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer', description: 'ID of the reply' }, + user_id: { type: 'integer', description: 'ID of the user who posted the reply' }, + comment_id: { type: 'integer', description: 'ID of the comment' }, + content: { type: 'string', description: 'Content of the reply' }, + created_at: { type: 'string', format: 'date-time', description: 'Date the reply was created' } + } + } + } + } + } + }, + 400: { + description: 'Error finding replies, invalid user ID.', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string', description: 'Error message' }, + code: { type: 'integer', example: 400 }, + suggestion: { type: 'string', description: 'Suggested action to resolve the issue' } + } + } + } + } + } + } +}); + +export +{ + createCommentReplyRouteDescription, + updateCommentReplyRouteDescription, + deleteDataCommentReplyRouteDescription, + deleteCommentReplyRouteDescription, + findReplyByCommentRouteDescription, + findAllReplyByCommentRouteDescription, + findAllReplyByUserRouteDescription +} \ No newline at end of file diff --git a/src/documentation/commentsDescribers.ts b/src/documentation/commentsDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5b8b24e846578461c9fccab5312592d1dac28f2 --- /dev/null +++ b/src/documentation/commentsDescribers.ts @@ -0,0 +1,413 @@ +import { describeRoute } from 'hono-openapi' + + +const createCommentRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new comment', + tags: ['Comments'], + requestBody: { + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + }, + required: ['user_id', 'resource_id', 'content'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Comment created successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + '400': { + description: 'Bad request', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + const updateCommentRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing comment', + tags: ['Comments'], + requestBody: { + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + required: ['id', 'content'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Comment updated successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + '400': { + description: 'Bad request', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + const deleteCommentDataRoute = describeRoute({ + method: 'POST', + path: 'deleteData/:id', + description: 'Delete comment data by ID', + tags: ['Comments'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + '200': { + description: 'Comment data deleted successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + deleted_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + '400': { + description: 'Bad request', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + const deleteCommentRoute = describeRoute({ + method: 'POST', + path: 'delete/:id', + description: 'Delete a comment by ID', + tags: ['Comments'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + }, + }, + ], + responses: { + '200': { + description: 'Comment deleted successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + resource_id: { type: 'integer' }, + content: { type: 'string' }, + deleted_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + '400': { + description: 'Bad request', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + +const findReplyByCommentRouteDescription = describeRoute({ + method: 'GET', + path: '/findReplyByComment/:comment_id', + description: 'Get active replies for a specific comment by its ID', + tags: ['Comments'], + parameters: [ + { + name: 'comment_id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the comment to find active replies for', + }, + }, + ], + responses: { + '200': { + description: 'Active replies found successfully', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer' }, + comment_id: { type: 'integer' }, + user_id: { type: 'integer' }, + reply_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error finding active replies for the comment', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + +const findAllReplyByCommentRouteDescription = describeRoute({ + method: 'GET', + path: '/findAllReplyByComment/:comment_id', + description: 'Get all replies for a specific comment by its ID', + tags: ['Comments'], + parameters: [ + { + name: 'comment_id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the comment to find all replies for', + }, + }, + ], + responses: { + '200': { + description: 'Replies found successfully', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer' }, + comment_id: { type: 'integer' }, + user_id: { type: 'integer' }, + reply_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error finding replies for the comment', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + +const findAllReplyByUserRouteDescription = describeRoute({ + method: 'GET', + path: '/findAllReplyByUser/:id_user', + description: 'Get all replies made by a specific user', + tags: ['Comments'], + parameters: [ + { + name: 'id_user', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the user to find their replies', + }, + }, + ], + responses: { + '200': { + description: 'Replies by user found successfully', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer' }, + comment_id: { type: 'integer' }, + user_id: { type: 'integer' }, + reply_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error finding replies for the user', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + +export +{ + createCommentRoute, + updateCommentRoute, + deleteCommentDataRoute, + deleteCommentRoute, + findReplyByCommentRouteDescription, + findAllReplyByCommentRouteDescription, + findAllReplyByUserRouteDescription +} \ No newline at end of file diff --git a/src/documentation/compliantDescribers.ts b/src/documentation/compliantDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfe756177d6ea3068ef36beb15898c70ea9e9474 --- /dev/null +++ b/src/documentation/compliantDescribers.ts @@ -0,0 +1,371 @@ +import { describeRoute } from 'hono-openapi' + + + const createComplaintRouteDescription = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new complaint', + tags: ['Complaints'], + requestBody: { + description: 'Complaint input data', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + user_id: { type: 'integer' }, + complaint_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + required: ['user_id', 'complaint_text'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Complaint created successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + complaint: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + complaint_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error creating complaint', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + // Route to update a complaint + const updateComplaintRouteDescription = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing complaint', + tags: ['Complaints'], + requestBody: { + description: 'Complaint update data', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + complaint_text: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + required: ['id', 'complaint_text'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Complaint updated successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + complaint: { + type: 'object', + properties: { + id: { type: 'integer' }, + complaint_text: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error updating complaint', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + // Route to evaluate a complaint + const evaluateComplaintRouteDescription = describeRoute({ + method: 'POST', + path: '/evaluate', + description: 'Evaluate an existing complaint', + tags: ['Complaints'], + requestBody: { + description: 'Complaint evaluation data', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + id: { type: 'integer' }, + status: { type: 'string', enum: ['pending', 'resolved', 'dismissed'] }, + evaluation_comments: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + required: ['id', 'status'], + }, + }, + }, + }, + responses: { + '200': { + description: 'Complaint evaluated successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + complaint: { + type: 'object', + properties: { + id: { type: 'integer' }, + status: { type: 'string' }, + evaluation_comments: { type: 'string' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error evaluating complaint', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + // Route to delete a complaint + const deleteComplaintRouteDescription = describeRoute({ + method: 'POST', + path: '/delete/:id', + description: 'Delete a complaint by ID', + tags: ['Complaints'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the complaint to delete', + }, + }, + ], + responses: { + '200': { + description: 'Complaint deleted successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + complaint: { + type: 'object', + properties: { + id: { type: 'integer' }, + complaint_text: { type: 'string' }, + deleted_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + }, + '400': { + description: 'Error deleting complaint', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + // Route to get a complaint by ID + const getComplaintByIdRouteDescription = describeRoute({ + method: 'GET', + path: '/:id', + description: 'Get a complaint by ID', + tags: ['Complaints'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'integer', + description: 'ID of the complaint to retrieve', + }, + }, + ], + responses: { + '200': { + description: 'Complaint found successfully', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + complaint: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + complaint_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + }, + '404': { + description: 'Complaint not found', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + // Route to get all complaints +const getAllComplaintsRouteDescription = describeRoute({ + method: 'GET', + path: '/', + description: 'Get all complaints', + tags: ['Complaints'], + responses: { + '200': { + description: 'Complaints found successfully', + content: { + 'application/json': { + schema: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'integer' }, + user_id: { type: 'integer' }, + complaint_text: { type: 'string' }, + created_at: { type: 'string', format: 'date-time' }, + updated_at: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + }, + '404': { + description: 'No complaints found', + content: { + 'application/json': { + schema: { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }); + + +export +{ + createComplaintRouteDescription, + updateComplaintRouteDescription, + evaluateComplaintRouteDescription, + deleteComplaintRouteDescription, + getComplaintByIdRouteDescription, + getAllComplaintsRouteDescription +} \ No newline at end of file diff --git a/src/documentation/institutionDescribers.ts b/src/documentation/institutionDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ac8d5af3be9c823bed1473c3ce574d8ad8d1f86 --- /dev/null +++ b/src/documentation/institutionDescribers.ts @@ -0,0 +1,375 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createInstitutionRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new institution.', + tags: ['Institution'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + required: ['name', 'uf', 'city', 'cep', 'address'], + }, + }, + }, + responses: { + 200: { + description: 'Institution created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /institutions + const getInstitutionsRoute = describeRoute({ + method: 'GET', + path: '/institutions', + description: 'Get a list of all institutions.', + tags: ['Institution'], + responses: { + 200: { + description: 'List of institutions.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + 404: { + description: 'Not found. No institutions found.', + }, + }, +}); + +// Descrição da rota /name/:name + const getInstitutionByNameRoute = describeRoute({ + method: 'GET', + path: '/name/{name}', + description: 'Get institution by name.', + tags: ['Institution'], + parameters: [ + { + name: 'name', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Institution found by name.', + content: { + 'application/json': { + type: 'object', + properties: { + institution: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Not found. Institution with the given name does not exist.', + }, + }, +}); + +// Descrição da rota /uf/:uf + const getInstitutionByUfRoute = describeRoute({ + method: 'GET', + path: '/uf/{uf}', + description: 'Get institution by UF (state).', + tags: ['Institution'], + parameters: [ + { + name: 'uf', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Institution found by UF.', + content: { + 'application/json': { + type: 'object', + properties: { + institution: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Not found. Institution with the given UF does not exist.', + }, + }, +}); + +// Descrição da rota /city/:city + const getInstitutionByCityRoute = describeRoute({ + method: 'GET', + path: '/city/{city}', + description: 'Get institution by city.', + tags: ['Institution'], + parameters: [ + { + name: 'city', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Institution found by city.', + content: { + 'application/json': { + type: 'object', + properties: { + institution: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Not found. Institution with the given city does not exist.', + }, + }, +}); + +// Descrição da rota /cep/:cep + const getInstitutionByCepRoute = describeRoute({ + method: 'GET', + path: '/cep/{cep}', + description: 'Get institution by CEP.', + tags: ['Institution'], + parameters: [ + { + name: 'cep', + in: 'path', + required: true, + schema: { + type: 'string', + }, + }, + ], + responses: { + 200: { + description: 'Institution found by CEP.', + content: { + 'application/json': { + type: 'object', + properties: { + institution: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Not found. Institution with the given CEP does not exist.', + }, + }, +}); + +// Descrição da rota /update + const updateInstitutionRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing institution.', + tags: ['Institution'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + required: ['id', 'name', 'uf', 'city', 'cep', 'address'], + }, + }, + }, + responses: { + 200: { + description: 'Institution updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + institution: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteInstitutionRoute = describeRoute({ + method: 'DELETE', + path: '/delete/{id}', + description: 'Delete an institution by ID.', + tags: ['Institution'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Institution deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + uf: { type: 'string' }, + city: { type: 'string' }, + cep: { type: 'string' }, + address: { type: 'string' }, + }, + }, + }, + }, + 404: { + description: 'Not found. Institution with the given ID does not exist.', + }, + }, +}); + +export{ + createInstitutionRoute, + getInstitutionsRoute, + getInstitutionByNameRoute, + getInstitutionByUfRoute, + getInstitutionByCityRoute, + getInstitutionByCepRoute, + updateInstitutionRoute, + deleteInstitutionRoute +} \ No newline at end of file diff --git a/src/documentation/languageDescriber.ts b/src/documentation/languageDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ab8d499e9093ba66d644be95da1e7c041f005c5 --- /dev/null +++ b/src/documentation/languageDescriber.ts @@ -0,0 +1,268 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createLanguageRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new language.', + tags: ['Language'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + code: { type: 'string' }, + }, + required: ['name', 'code'], + }, + }, + }, + responses: { + 200: { + description: 'Language created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + language: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateLanguageRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing language.', + tags: ['Language'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + required: ['id', 'name', 'code'], + }, + }, + }, + responses: { + 200: { + description: 'Language updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + language: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteLanguageRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete a language by ID.', + tags: ['Language'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Language deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + language: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all (public route) + const getAllLanguagesRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get a list of all languages.', + tags: ['Language'], + responses: { + 200: { + description: 'List of languages.', + content: { + 'application/json': { + type: 'object', + properties: { + languages: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find languages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id (public route) + const getLanguageByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get a language by ID.', + tags: ['Language'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Language found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + language: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + code: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find language.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createLanguageRoute, + updateLanguageRoute, + deleteLanguageRoute, + getAllLanguagesRoute, + getLanguageByIdRoute +} \ No newline at end of file diff --git a/src/documentation/licenseDescriber.ts b/src/documentation/licenseDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..51c4444178df233fbec5aeb70bb6176218d3ba01 --- /dev/null +++ b/src/documentation/licenseDescriber.ts @@ -0,0 +1,274 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota /create + const createLicenseRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new license.', + tags: ['License'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + required: ['name', 'type', 'validity'], + }, + }, + }, + responses: { + 200: { + description: 'License created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + license: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateLicenseRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing license.', + tags: ['License'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + required: ['id', 'name', 'type', 'validity'], + }, + }, + }, + responses: { + 200: { + description: 'License updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + license: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteLicenseRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete a license by ID.', + tags: ['License'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'License deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + license: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all (public route) + const getAllLicensesRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get a list of all licenses.', + tags: ['License'], + responses: { + 200: { + description: 'List of licenses.', + content: { + 'application/json': { + type: 'object', + properties: { + licenses: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find licenses.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id (public route) + const getLicenseByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get a license by ID.', + tags: ['License'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'License found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + license: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + type: { type: 'string' }, + validity: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Could not find license.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createLicenseRoute, + updateLicenseRoute, + deleteLicenseRoute, + getAllLicensesRoute, + getLicenseByIdRoute +} diff --git a/src/documentation/notificationDescriber.ts b/src/documentation/notificationDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2391bebcd27a2acd07ecbc76d05ea2ae5ff150a --- /dev/null +++ b/src/documentation/notificationDescriber.ts @@ -0,0 +1,524 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createNotificationRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new notification.', + tags: ['Notification'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + required: ['action_id', 'actor_user_id', 'target_user_id', 'message'], + }, + }, + }, + responses: { + 200: { + description: 'Notification created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /notifications + const getNotificationsRoute = describeRoute({ + method: 'GET', + path: '/notifications', + description: 'Get a list of all notifications.', + tags: ['Notification'], + responses: { + 200: { + description: 'List of notifications.', + content: { + 'application/json': { + type: 'object', + properties: { + notifications: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notifications not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /action/:action_id + const getNotificationByActionRoute = describeRoute({ + method: 'GET', + path: '/action/{action_id}', + description: 'Get a notification by action ID.', + tags: ['Notification'], + parameters: [ + { + name: 'action_id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification found by action ID.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notification not found by action ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /actor-user/:actor_user_id + const getNotificationByActorUserRoute = describeRoute({ + method: 'GET', + path: '/actor-user/{actor_user_id}', + description: 'Get a notification by actor user ID.', + tags: ['Notification'], + parameters: [ + { + name: 'actor_user_id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification found by actor user ID.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notification not found by actor user ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /target-user/:target_user_id + const getNotificationByTargetUserRoute = describeRoute({ + method: 'GET', + path: '/target-user/{target_user_id}', + description: 'Get a notification by target user ID.', + tags: ['Notification'], + parameters: [ + { + name: 'target_user_id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification found by target user ID.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notification not found by target user ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /target-resource/:target_resource_id + const getNotificationByTargetResourceRoute = describeRoute({ + method: 'GET', + path: '/target-resource/{target_resource_id}', + description: 'Get a notification by target resource ID.', + tags: ['Notification'], + parameters: [ + { + name: 'target_resource_id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification found by target resource ID.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notification not found by target resource ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /target-collection/:target_collection_id + const getNotificationByTargetCollectionRoute = describeRoute({ + method: 'GET', + path: '/target-collection/{target_collection_id}', + description: 'Get a notification by target collection ID.', + tags: ['Notification'], + parameters: [ + { + name: 'target_collection_id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification found by target collection ID.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 404: { + description: 'Notification not found by target collection ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateNotificationRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing notification.', + tags: ['Notification'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + required: ['id', 'action_id', 'actor_user_id', 'target_user_id', 'message'], + }, + }, + }, + responses: { + 200: { + description: 'Notification updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteNotificationRoute = describeRoute({ + method: 'DELETE', + path: '/delete/{id}', + description: 'Delete a notification by ID.', + tags: ['Notification'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Notification deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + notification: { + type: 'object', + properties: { + id: { type: 'number' }, + action_id: { type: 'number' }, + actor_user_id: { type: 'number' }, + target_user_id: { type: 'number' }, + target_resource_id: { type: 'number' }, + target_collection_id: { type: 'number' }, + message: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createNotificationRoute, + getNotificationsRoute, + getNotificationByActionRoute, + getNotificationByActorUserRoute, + getNotificationByTargetUserRoute, + getNotificationByTargetResourceRoute, + getNotificationByTargetCollectionRoute, + updateNotificationRoute, + deleteNotificationRoute +} \ No newline at end of file diff --git a/src/documentation/object-type.ts b/src/documentation/object-type.ts new file mode 100644 index 0000000000000000000000000000000000000000..caf961ebbf10ecc427c615963a20aa90a5729b46 --- /dev/null +++ b/src/documentation/object-type.ts @@ -0,0 +1,263 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createObjectTypeRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new object type.', + tags: ['Object-Type'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['name'], + }, + }, + }, + responses: { + 200: { + description: 'Object type created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + objectType: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateObjectTypeRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing object type.', + tags: ['Object-Type'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['id', 'name'], + }, + }, + }, + responses: { + 200: { + description: 'Object type updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + objectType: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid input.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteObjectTypeRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete an object type by ID.', + tags: ['Object-Type'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Object type deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + objectType: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Invalid ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all + const getAllObjectTypesRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get a list of all object types.', + tags: ['Object-Type'], + responses: { + 200: { + description: 'List of all object types.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Unable to fetch object types.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id + const getObjectTypeByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get an object type by ID.', + tags: ['Object-Type'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { + type: 'number', + }, + }, + ], + responses: { + 200: { + description: 'Object type found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + objectType: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + }, + 400: { + description: 'Bad request. Object type not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createObjectTypeRoute, + updateObjectTypeRoute, + deleteObjectTypeRoute, + getAllObjectTypesRoute, + getObjectTypeByIdRoute +} diff --git a/src/documentation/resource-educational-stages.ts b/src/documentation/resource-educational-stages.ts new file mode 100644 index 0000000000000000000000000000000000000000..9641ffb8a98363bcc7649cb2b4d5094307855f01 --- /dev/null +++ b/src/documentation/resource-educational-stages.ts @@ -0,0 +1,303 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /associate + const associateResourceWithEducationalStagesRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate educational stages with a resource.', + tags: ['Resource-Educational-Stages'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + educationalStageIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'educationalStageIds'], + }, + }, + }, + responses: { + 200: { + description: 'Educational stages associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate educational stages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/delete/educationalStage/:educationalStageId + const removeEducationalStageFromResourceRoute = describeRoute({ + method: 'POST', + path: '/{resourceId}/delete/educationalStage/{educationalStageId}', + description: 'Remove an educational stage from a resource.', + tags: ['Resource-Educational-Stages'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'educationalStageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Educational stage removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove educational stage.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update/educationalStages + const updateResourceEducationalStagesRoute = describeRoute({ + method: 'POST', + path: '/update/educationalStages', + description: 'Update educational stages for a resource.', + tags: ['Resource-Educational-Stages'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + educationalStageIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'educationalStageIds'], + }, + }, + }, + responses: { + 200: { + description: 'Educational stages updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update educational stages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/educationalStages + const getEducationalStagesByResourceRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/educationalStages', + description: 'Get educational stages associated with a resource.', + tags: ['Resource-Educational-Stages'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of educational stages associated with the resource.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to get educational stages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/educationalStages/:educationalStageId/exists + const checkAssociationExistsRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/educationalStages/{educationalStageId}/exists', + description: 'Check if an association exists between a resource and an educational stage.', + tags: ['Resource-Educational-Stages'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'educationalStageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Association exists.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /educationalStage/:educationalStageId/resources + const getResourcesByEducationalStageRoute = describeRoute({ + method: 'GET', + path: '/educationalStage/{educationalStageId}/resources', + description: 'Get resources associated with an educational stage.', + tags: ['Resource-Educational-Stages'], + parameters: [ + { + name: 'educationalStageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of resources associated with the educational stage.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to get resources.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + associateResourceWithEducationalStagesRoute, + removeEducationalStageFromResourceRoute, + updateResourceEducationalStagesRoute, + getEducationalStagesByResourceRoute, + checkAssociationExistsRoute, + getResourcesByEducationalStageRoute +} \ No newline at end of file diff --git a/src/documentation/resource-language.ts b/src/documentation/resource-language.ts new file mode 100644 index 0000000000000000000000000000000000000000..2be34e664f243c86e1c778d14f3449543ed96324 --- /dev/null +++ b/src/documentation/resource-language.ts @@ -0,0 +1,302 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota /associate + const associateResourceWithLanguagesRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate a resource with multiple languages.', + tags: ['Resource-Language'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + languageIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'languageIds'], + }, + }, + }, + responses: { + 200: { + description: 'Languages associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate languages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/delete/language/:languageId + const removeLanguageFromResourceRoute = describeRoute({ + method: 'POST', + path: '/{resourceId}/delete/language/{languageId}', + description: 'Remove the association between a resource and a language.', + tags: ['Resource-Language'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'languageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Language removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove language.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update/languages + const updateResourceLanguagesRoute = describeRoute({ + method: 'POST', + path: '/update/languages', + description: 'Update the language associations for a resource.', + tags: ['Resource-Language'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + languageIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'languageIds'], + }, + }, + }, + responses: { + 200: { + description: 'Languages updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update languages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/languages + const getLanguagesByResourceRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/languages', + description: 'Get all languages associated with a resource.', + tags: ['Resource-Language'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of languages associated with the resource.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch languages.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/language/:languageId/exists + const checkLanguageAssociationExistsRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/language/{languageId}/exists', + description: 'Check if the association between a resource and a language exists.', + tags: ['Resource-Language'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'languageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'The association exists or not.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check the association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /language/:languageId/resources + const getResourcesByLanguageRoute = describeRoute({ + method: 'GET', + path: '/language/{languageId}/resources', + description: 'Get all resources associated with a language.', + tags: ['Resource-Language'], + parameters: [ + { + name: 'languageId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of resources associated with the language.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch resources.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + associateResourceWithLanguagesRoute, + removeLanguageFromResourceRoute, + updateResourceLanguagesRoute, + getLanguagesByResourceRoute, + checkLanguageAssociationExistsRoute, + getResourcesByLanguageRoute +} \ No newline at end of file diff --git a/src/documentation/resource-likes.ts b/src/documentation/resource-likes.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ed6348f2180885c840e38e6d1122bccd1a721e0 --- /dev/null +++ b/src/documentation/resource-likes.ts @@ -0,0 +1,252 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota /associate + const associateResourceWithLikesRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate a resource with likes from multiple users.', + tags: ['Resource-Likes'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + userIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'userIds'], + }, + }, + }, + responses: { + 200: { + description: 'Likes associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate likes.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/delete/:userId + const removeLikesFromResourceRoute = describeRoute({ + method: 'POST', + path: '/{resourceId}/delete/{userId}', + description: 'Remove likes from a resource (unlike).', + tags: ['Resource-Likes'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'userId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Likes removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove likes.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId + const getLikesByResourceRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}', + description: 'Get all likes for a specific resource.', + tags: ['Resource-Likes'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of likes for the resource.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + userId: { type: 'number' }, + likedAt: { type: 'string', format: 'date-time' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch likes.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/likes/:userId/exists + const checkLikeAssociationExistsRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/likes/{userId}/exists', + description: 'Check if a user has liked a specific resource.', + tags: ['Resource-Likes'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'userId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Whether the user has liked the resource or not.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check like association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /user/:userId/resources + const getResourcesByUserRoute = describeRoute({ + method: 'GET', + path: '/user/{userId}/resources', + description: 'Get all resources liked by a specific user.', + tags: ['Resource-Likes'], + parameters: [ + { + name: 'userId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of resources liked by the user.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + resourceName: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch resources.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + + +export +{ + associateResourceWithLikesRoute, + removeLikesFromResourceRoute, + getLikesByResourceRoute, + checkLikeAssociationExistsRoute, + getResourcesByUserRoute +} \ No newline at end of file diff --git a/src/documentation/resource-statsDescriber.ts b/src/documentation/resource-statsDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..96c5449fb8bcaf08dec0b49e6292e55b1d8ba638 --- /dev/null +++ b/src/documentation/resource-statsDescriber.ts @@ -0,0 +1,367 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create stats for a resource.', + tags: ['Resource-Stats'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + views: { type: 'number' }, + shares: { type: 'number' }, + downloads: { type: 'number' }, + }, + required: ['resourceId', 'views', 'shares', 'downloads'], + }, + }, + }, + responses: { + 200: { + description: 'Stats created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to create stats resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update stats for a resource.', + tags: ['Resource-Stats'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + views: { type: 'number' }, + shares: { type: 'number' }, + downloads: { type: 'number' }, + }, + required: ['resourceId', 'views', 'shares', 'downloads'], + }, + }, + }, + responses: { + 200: { + description: 'Stats updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update stats resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete stats for a resource.', + tags: ['Resource-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Stats deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete stats resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /viewUpdate/:id + const viewUpdateResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/viewUpdate/{id}', + description: 'Update the views count of a resource (increments by 1).', + tags: ['Resource-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Views updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update views.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /sharesUpdate/:id + const sharesUpdateResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/sharesUpdate/{id}', + description: 'Update the shares count of a resource (increments by 1).', + tags: ['Resource-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Shares updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update shares.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /downloadUpdate/:id + const downloadUpdateResourceStatsRoute = describeRoute({ + method: 'POST', + path: '/downloadUpdate/{id}', + description: 'Update the downloads count of a resource (increments by 1).', + tags: ['Resource-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Downloads updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update downloads.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all + const getAllResourceStatsRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get all stats for all resources.', + tags: ['Resource-Stats'], + responses: { + 200: { + description: 'List of all stats for resources.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + views: { type: 'number' }, + shares: { type: 'number' }, + downloads: { type: 'number' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch stats resources.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id + const getResourceStatsByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get stats for a specific resource.', + tags: ['Resource-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Stats for the specific resource.', + content: { + 'application/json': { + type: 'object', + properties: { + statsResource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to fetch stats for the resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createResourceStatsRoute, + updateResourceStatsRoute, + deleteResourceStatsRoute, + viewUpdateResourceStatsRoute, + sharesUpdateResourceStatsRoute, + downloadUpdateResourceStatsRoute, + getAllResourceStatsRoute, + getResourceStatsByIdRoute +} \ No newline at end of file diff --git a/src/documentation/resource-subjectsDescriber.ts b/src/documentation/resource-subjectsDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb43bb845a0d335865c2db9cfa1a0dc9b2293232 --- /dev/null +++ b/src/documentation/resource-subjectsDescriber.ts @@ -0,0 +1,304 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /associate + const associateResourceWithSubjectsRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate subjects with a resource.', + tags: ['Resource-Subjects'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + subjectIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'subjectIds'], + }, + }, + }, + responses: { + 200: { + description: 'Subjects associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate subjects.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/delete/subject/:subjectId + const removeSubjectFromResourceRoute = describeRoute({ + method: 'POST', + path: '/{resourceId}/delete/subject/{subjectId}', + description: 'Remove a subject from a resource.', + tags: ['Resource-Subjects'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'subjectId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Subject removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove subject.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update/subjects + const updateResourceSubjectsRoute = describeRoute({ + method: 'POST', + path: '/update/subjects', + description: 'Update subjects associated with a resource.', + tags: ['Resource-Subjects'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + subjectIds: { + type: 'array', + items: { type: 'number' }, + }, + }, + required: ['resourceId', 'subjectIds'], + }, + }, + }, + responses: { + 200: { + description: 'Subjects updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update subjects.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/subjects + const getSubjectsByResourceRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/subjects', + description: 'Get all subjects associated with a resource.', + tags: ['Resource-Subjects'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of subjects associated with the resource.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + subjectId: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to get subjects.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:resourceId/subject/:subjectId/exists + const checkAssociationExistsRoute = describeRoute({ + method: 'GET', + path: '/{resourceId}/subject/{subjectId}/exists', + description: 'Check if a subject is associated with a resource.', + tags: ['Resource-Subjects'], + parameters: [ + { + name: 'resourceId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + { + name: 'subjectId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Whether the association exists or not.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /subject/:subjectId/resources + const getResourcesBySubjectRoute = describeRoute({ + method: 'GET', + path: '/subject/{subjectId}/resources', + description: 'Get all resources associated with a subject.', + tags: ['Resource-Subjects'], + parameters: [ + { + name: 'subjectId', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of resources associated with the subject.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to get resources.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + + +export +{ + associateResourceWithSubjectsRoute, + removeSubjectFromResourceRoute, + updateResourceSubjectsRoute, + getSubjectsByResourceRoute, + checkAssociationExistsRoute, + getResourcesBySubjectRoute +} \ No newline at end of file diff --git a/src/documentation/resourceDescriber.ts b/src/documentation/resourceDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..5cf529237e99dbab948f4a6b24843b1fdf1f477a --- /dev/null +++ b/src/documentation/resourceDescriber.ts @@ -0,0 +1,417 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota /create + const createResourceRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new resource.', + tags: ['Resources'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['name', 'description'], + }, + }, + }, + responses: { + 200: { + description: 'Resource created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + resource: { type: 'object' }, + stats: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to create resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateResourceRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing resource.', + tags: ['Resources'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['id'], + }, + }, + }, + responses: { + 200: { + description: 'Resource updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + resource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /deleteData/:id + const deleteResourceDataRoute = describeRoute({ + method: 'POST', + path: '/deleteData/{id}', + description: 'Delete resource data by its ID.', + tags: ['Resources'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Resource data deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + resource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete resource data.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteResourceRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete a resource by its ID.', + tags: ['Resources'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Resource deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + resource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /active/:id + const activateResourceRoute = describeRoute({ + method: 'POST', + path: '/active/{id}', + description: 'Activate a resource by its ID.', + tags: ['Resources'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Resource activated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + resource: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to activate resource.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all + const getAllResourcesRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get all resources.', + tags: ['Resources'], + responses: { + 200: { + description: 'List of all resources.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + 404: { + description: 'No resources found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /allResourceByUser/:user_id + const getAllResourcesByUserRoute = describeRoute({ + method: 'GET', + path: '/allResourceByUser/{user_id}', + description: 'Get all resources by a user ID.', + tags: ['Resources'], + parameters: [ + { + name: 'user_id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of resources for the user.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to find resources by user.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /activeResourceByUser/:user_id + const getActiveResourcesByUserRoute = describeRoute({ + method: 'GET', + path: '/activeResourceByUser/{user_id}', + description: 'Get active resources by a user ID.', + tags: ['Resources'], + parameters: [ + { + name: 'user_id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'List of active resources for the user.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + resourceId: { type: 'number' }, + name: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to find active resources by user.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id + const getResourceByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get a resource by its ID.', + tags: ['Resources'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Resource found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + resourceId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to find resource by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createResourceRoute, + updateResourceRoute, + deleteResourceDataRoute, + deleteResourceRoute, + activateResourceRoute, + getAllResourcesRoute, + getAllResourcesByUserRoute, + getActiveResourcesByUserRoute, + getResourceByIdRoute +} diff --git a/src/documentation/roleDescriber.ts b/src/documentation/roleDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb655325d4b5ebd4e2f6c60d9c4eb5c723a2f06f --- /dev/null +++ b/src/documentation/roleDescriber.ts @@ -0,0 +1,233 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createRoleRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new role.', + tags: ['Role'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['name'], + }, + }, + }, + responses: { + 200: { + description: 'Role created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + role: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to create role.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /roles + const getRolesRoute = describeRoute({ + method: 'GET', + path: '/roles', + description: 'Get a list of all roles.', + tags: ['Role'], + responses: { + 200: { + description: 'List of all roles.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + roleId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + 404: { + description: 'No roles found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:name + const getRoleByNameRoute = describeRoute({ + method: 'GET', + path: '/{name}', + description: 'Get a role by its name.', + tags: ['Role'], + parameters: [ + { + name: 'name', + in: 'path', + required: true, + schema: { type: 'string' }, + }, + ], + responses: { + 200: { + description: 'Role found by name.', + content: { + 'application/json': { + type: 'object', + properties: { + roleId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + 404: { + description: 'Role not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateRoleRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing role.', + tags: ['Role'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['id'], + }, + }, + }, + responses: { + 200: { + description: 'Role updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + role: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update role.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteRoleRoute = describeRoute({ + method: 'DELETE', + path: '/delete/{id}', + description: 'Delete a role by its ID.', + tags: ['Role'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Role deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + role: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete role.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createRoleRoute, + getRolesRoute, + getRoleByNameRoute, + updateRoleRoute, + deleteRoleRoute +} \ No newline at end of file diff --git a/src/documentation/s3Describers.ts b/src/documentation/s3Describers.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9ccb293bc35e5948f40e4c23a9170f561bce7d9 --- /dev/null +++ b/src/documentation/s3Describers.ts @@ -0,0 +1,453 @@ +import { describeRoute } from "hono-openapi"; + + +const uploadResourceRoute = describeRoute({ + method: "POST", + path: "/upload/resource/:id_resource", + tags: ["S3"], + summary: "Faz o upload de um recurso para o S3", + description: "Permite o upload de arquivos de até 5GB e os armazena no bucket S3.", + parameters: [ + { + name: "id_resource", + in: "path", + required: true, + description: "O ID do recurso que será armazenado.", + schema: { type: "string" } + } + ], + requestBody: { + required: true, + content: { + "multipart/form-data": { + schema: { + type: "object", + properties: { + file: { + type: "string", + format: "binary", + description: "Arquivo a ser enviado (máx. 5GB)" + } + } + } + } + } + }, + responses: { + 200: { + description: "Upload bem-sucedido.", + content: { "application/json": { example: { message: "Arquivo enviado com sucesso!", status: "success" } } } + }, + 400: { + description: "Erro de validação, como arquivo ausente ou excedendo limite.", + content: { "application/json": { example: { message: "O arquivo excede o limite de 5GB.", status: "error" } } } + }, + 500: { + description: "Erro interno ao enviar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao enviar o arquivo.", status: "error" } } } + } + } +}); + +// Rota para upload de thumbnail de um recurso no S3 +const uploadThumbnailResourceRoute = describeRoute({ + method: "POST", + path: "/upload/thumbnail/resource/:id_resource", + tags: ["S3"], + summary: "Faz o upload de uma thumbnail de recurso", + description: "Permite o upload de thumbnails de recursos de até 1MB.", + parameters: [ + { + name: "id_resource", + in: "path", + required: true, + description: "O ID do recurso ao qual a thumbnail pertence.", + schema: { type: "string" } + } + ], + requestBody: { + required: true, + content: { + "multipart/form-data": { + schema: { + type: "object", + properties: { + file: { + type: "string", + format: "binary", + description: "Thumbnail a ser enviada (máx. 1MB)" + } + } + } + } + } + }, + responses: { + 200: { + description: "Upload bem-sucedido.", + content: { "application/json": { example: { message: "Arquivo enviado com sucesso!", status: "success" } } } + }, + 400: { + description: "Erro de validação, como arquivo ausente ou excedendo limite.", + content: { "application/json": { example: { message: "A thumbnail do recurso excede o limite de 1MB.", status: "error" } } } + }, + 500: { + description: "Erro interno ao enviar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao enviar o arquivo.", status: "error" } } } + } + } +}); + +// Rota para upload de thumbnail de uma coleção no S3 +const uploadThumbnailCollectionRoute = describeRoute({ + method: "POST", + path: "/upload/thumbnail/collection/:id_collection", + tags: ["S3"], + summary: "Faz o upload de uma thumbnail de coleção", + description: "Permite o upload de thumbnails de coleções de até 1MB.", + parameters: [ + { + name: "id_collection", + in: "path", + required: true, + description: "O ID da coleção à qual a thumbnail pertence.", + schema: { type: "string" } + } + ], + requestBody: { + required: true, + content: { + "multipart/form-data": { + schema: { + type: "object", + properties: { + file: { + type: "string", + format: "binary", + description: "Thumbnail a ser enviada (máx. 1MB)" + } + } + } + } + } + }, + responses: { + 200: { + description: "Upload bem-sucedido.", + content: { "application/json": { example: { message: "Arquivo enviado com sucesso!", status: "success" } } } + }, + 400: { + description: "Erro de validação, como arquivo ausente ou excedendo limite.", + content: { "application/json": { example: { message: "A thumbnail da coleção excede o limite de 1MB.", status: "error" } } } + }, + 500: { + description: "Erro interno ao enviar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao enviar o arquivo.", status: "error" } } } + } + } +}); + +// Rota para upload de avatar no S3 +const uploadAvatarRoute = describeRoute({ + method: "POST", + path: "/upload/avatar/:id_avatar", + tags: ["S3"], + summary: "Faz o upload de um avatar", + description: "Permite o upload de avatares de até 5MB para o S3.", + parameters: [ + { + name: "id_avatar", + in: "path", + required: true, + description: "O ID do avatar a ser armazenado.", + schema: { type: "string" } + } + ], + requestBody: { + required: true, + content: { + "multipart/form-data": { + schema: { + type: "object", + properties: { + file: { + type: "string", + format: "binary", + description: "Avatar a ser enviado (máx. 5MB)" + } + } + } + } + } + }, + responses: { + 200: { + description: "Upload bem-sucedido.", + content: { "application/json": { example: { message: "Arquivo enviado com sucesso!", status: "success" } } } + }, + 400: { + description: "Erro de validação, como arquivo ausente ou excedendo limite.", + content: { "application/json": { example: { message: "O avatar excede o limite de 5MB.", status: "error" } } } + }, + 500: { + description: "Erro interno ao enviar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao enviar o arquivo.", status: "error" } } } + } + } +}); + +// Rota para deletar um recurso do S3 +const deleteResourceRoute = describeRoute({ + method: "POST", + path: "/delete/resource/:id", + tags: ["S3"], + summary: "Deleta um recurso do S3", + description: "Remove um recurso específico do bucket S3.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID do recurso a ser deletado.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Recurso deletado com sucesso.", + content: { "application/json": { example: { message: "Recurso deletado com sucesso." } } } + }, + 500: { + description: "Erro ao deletar o recurso.", + content: { "application/json": { example: { error: "Erro ao deletar objeto do S3." } } } + } + } +}); + +// Rota para deletar um avatar do S3 +const deleteAvatarRoute = describeRoute({ + method: "POST", + path: "/delete/avatar/:id", + tags: ["S3"], + summary: "Deleta um avatar do S3", + description: "Remove um avatar específico do bucket S3.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID do avatar a ser deletado.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Avatar deletado com sucesso.", + content: { "application/json": { example: { message: "Avatar deletado com sucesso." } } } + }, + 500: { + description: "Erro ao deletar o avatar.", + content: { "application/json": { example: { error: "Erro ao deletar objeto do S3." } } } + } + } +}); + +// Rota para deletar a thumbnail de um recurso no S3 +const deleteThumbnailResourceRoute = describeRoute({ + method: "POST", + path: "/delete/thumbnail/resource/:id", + tags: ["S3"], + summary: "Deleta a thumbnail de um recurso do S3", + description: "Remove a thumbnail associada a um recurso do bucket S3.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID da thumbnail do recurso a ser deletada.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Thumbnail deletada com sucesso.", + content: { "application/json": { example: { message: "Thumbnail deletada com sucesso." } } } + }, + 500: { + description: "Erro ao deletar a thumbnail.", + content: { "application/json": { example: { error: "Erro ao deletar objeto do S3." } } } + } + } +}); + +// Rota para deletar a thumbnail de uma coleção no S3 +const deleteThumbnailCollectionRoute = describeRoute({ + method: "POST", + path: "/delete/thumbnail/collection/:id", + tags: ["S3"], + summary: "Deleta a thumbnail de uma coleção do S3", + description: "Remove a thumbnail associada a uma coleção do bucket S3.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID da thumbnail da coleção a ser deletada.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Thumbnail deletada com sucesso.", + content: { "application/json": { example: { message: "Thumbnail deletada com sucesso." } } } + }, + 500: { + description: "Erro ao deletar a thumbnail.", + content: { "application/json": { example: { error: "Erro ao deletar objeto do S3." } } } + } + } +}); + +// Rota para obter um recurso do S3 +const getResourceRoute = describeRoute({ + method: "GET", + path: "/get/resource/:id", + tags: ["S3"], + summary: "Obtém um recurso do S3", + description: "Recupera um arquivo de recurso do bucket S3 com base no ID fornecido.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID do recurso a ser recuperado.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Recurso obtido com sucesso.", + content: { "application/octet-stream": {} } + }, + 404: { + description: "Arquivo não encontrado.", + content: { "application/json": { example: { message: "Arquivo não encontrado" } } } + }, + 500: { + description: "Erro interno ao buscar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao buscar o arquivo" } } } + } + } +}); + +// Rota para obter uma thumbnail de recurso do S3 +const getThumbnailResourceRoute = describeRoute({ + method: "GET", + path: "/get/thumbnail/resource/:id", + tags: ["S3"], + summary: "Obtém uma thumbnail de recurso do S3", + description: "Recupera a thumbnail de um recurso do bucket S3 com base no ID fornecido.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID da thumbnail do recurso a ser recuperada.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Thumbnail de recurso obtida com sucesso.", + content: { "application/octet-stream": {} } + }, + 404: { + description: "Arquivo não encontrado.", + content: { "application/json": { example: { message: "Arquivo não encontrado" } } } + }, + 500: { + description: "Erro interno ao buscar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao buscar o arquivo" } } } + } + } +}); + +// Rota para obter uma thumbnail de coleção do S3 +const getThumbnailCollectionRoute = describeRoute({ + method: "GET", + path: "/get/thumbnail/collection/:id", + tags: ["S3"], + summary: "Obtém uma thumbnail de coleção do S3", + description: "Recupera a thumbnail de uma coleção do bucket S3 com base no ID fornecido.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID da thumbnail da coleção a ser recuperada.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Thumbnail de coleção obtida com sucesso.", + content: { "application/octet-stream": {} } + }, + 404: { + description: "Arquivo não encontrado.", + content: { "application/json": { example: { message: "Arquivo não encontrado" } } } + }, + 500: { + description: "Erro interno ao buscar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao buscar o arquivo" } } } + } + } +}); + +// Rota para obter um avatar do S3 +const getAvatarRoute = describeRoute({ + method: "GET", + path: "/get/avatar/:id", + tags: ["S3"], + summary: "Obtém um avatar do S3", + description: "Recupera um avatar do bucket S3 com base no ID fornecido.", + parameters: [ + { + name: "id", + in: "path", + required: true, + description: "O ID do avatar a ser recuperado.", + schema: { type: "string" } + } + ], + responses: { + 200: { + description: "Avatar obtido com sucesso.", + content: { "application/octet-stream": {} } + }, + 404: { + description: "Arquivo não encontrado.", + content: { "application/json": { example: { message: "Arquivo não encontrado" } } } + }, + 500: { + description: "Erro interno ao buscar o arquivo.", + content: { "application/json": { example: { message: "Erro interno ao buscar o arquivo" } } } + } + } +}); + +export +{ + uploadResourceRoute, + uploadThumbnailResourceRoute, + uploadThumbnailCollectionRoute, + uploadAvatarRoute, + deleteResourceRoute, + deleteAvatarRoute, + deleteThumbnailResourceRoute, + deleteThumbnailCollectionRoute, + getResourceRoute, + getThumbnailResourceRoute, + getThumbnailCollectionRoute, + getAvatarRoute +} \ No newline at end of file diff --git a/src/documentation/subjectsDescriber.ts b/src/documentation/subjectsDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..004e74799f5616ef41d2f1693c5469473b19cdee --- /dev/null +++ b/src/documentation/subjectsDescriber.ts @@ -0,0 +1,233 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /create + const createSubjectRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new subject.', + tags: ['Subjects'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['name'], + }, + }, + }, + responses: { + 200: { + description: 'Subject created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + subject: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to create subject.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateSubjectRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing subject.', + tags: ['Subjects'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + required: ['id'], + }, + }, + }, + responses: { + 200: { + description: 'Subject updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + subject: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update subject.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteSubjectRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete a subject by its ID.', + tags: ['Subjects'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Subject deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + subject: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete subject.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /all + const getAllSubjectsRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get a list of all subjects.', + tags: ['Subjects'], + responses: { + 200: { + description: 'List of all subjects.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + subjectId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to find subjects.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id + const getSubjectByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get a subject by its ID.', + tags: ['Subjects'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Subject found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + subjectId: { type: 'number' }, + name: { type: 'string' }, + description: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to find subject.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createSubjectRoute, + updateSubjectRoute, + deleteSubjectRoute, + getAllSubjectsRoute, + getSubjectByIdRoute +} \ No newline at end of file diff --git a/src/documentation/submissionsDescriber.ts b/src/documentation/submissionsDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..4daaf663879eb20d46b753a3be69fbe258733592 --- /dev/null +++ b/src/documentation/submissionsDescriber.ts @@ -0,0 +1,286 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota /create + const createSubmissionRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create a new submission.', + tags: ['Submissions'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + userId: { type: 'number' }, + resourceId: { type: 'number' }, + content: { type: 'string' }, + }, + required: ['userId', 'resourceId', 'content'], + }, + }, + }, + responses: { + 200: { + description: 'Submission created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + submission: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to create submission.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /update + const updateSubmissionRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update an existing submission.', + tags: ['Submissions'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + id: { type: 'number' }, + userId: { type: 'number' }, + resourceId: { type: 'number' }, + content: { type: 'string' }, + }, + required: ['id', 'userId', 'resourceId', 'content'], + }, + }, + }, + responses: { + 200: { + description: 'Submission updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + submission: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update submission.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /answer + const answerSubmissionRoute = describeRoute({ + method: 'POST', + path: '/answer', + description: 'Submit an answer to an existing submission.', + tags: ['Submissions'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + submissionId: { type: 'number' }, + answer: { type: 'string' }, + }, + required: ['submissionId', 'answer'], + }, + }, + }, + responses: { + 200: { + description: 'Submission answered successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + submission: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to answer submission.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /delete/:id + const deleteSubmissionRoute = describeRoute({ + method: 'POST', + path: '/delete/{id}', + description: 'Delete a submission by its ID.', + tags: ['Submissions'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Submission deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + submission: { type: 'object' }, + }, + }, + }, + }, + 400: { + description: 'Failed to delete submission.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota /:id + const getSubmissionByIdRoute = describeRoute({ + method: 'GET', + path: '/{id}', + description: 'Get a submission by its ID.', + tags: ['Submissions'], + parameters: [ + { + name: 'id', + in: 'path', + required: true, + schema: { type: 'number' }, + }, + ], + responses: { + 200: { + description: 'Submission found by ID.', + content: { + 'application/json': { + type: 'object', + properties: { + submissionId: { type: 'number' }, + userId: { type: 'number' }, + resourceId: { type: 'number' }, + content: { type: 'string' }, + answer: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to find submission.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota / + const getAllSubmissionsRoute = describeRoute({ + method: 'GET', + path: '/', + description: 'Get a list of all submissions.', + tags: ['Submissions'], + responses: { + 200: { + description: 'List of all submissions.', + content: { + 'application/json': { + type: 'array', + items: { + type: 'object', + properties: { + submissionId: { type: 'number' }, + userId: { type: 'number' }, + resourceId: { type: 'number' }, + content: { type: 'string' }, + answer: { type: 'string' }, + }, + }, + }, + }, + }, + 400: { + description: 'Failed to find submissions.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string' }, + message: { type: 'string' }, + code: { type: 'integer' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createSubmissionRoute, + updateSubmissionRoute, + answerSubmissionRoute, + deleteSubmissionRoute, + getSubmissionByIdRoute, + getAllSubmissionsRoute +} \ No newline at end of file diff --git a/src/documentation/uploaderDescriber.ts b/src/documentation/uploaderDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..26dc687ced78cf12d6fa2caa6d72e91dd644f5cc --- /dev/null +++ b/src/documentation/uploaderDescriber.ts @@ -0,0 +1,50 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota /users (upload de arquivo) +const uploadUsersRoute = describeRoute({ + method: 'POST', + path: '/users', + description: 'Upload a CSV file containing user data.', + tags: ['Uploader'], + requestBody: { + content: { + 'multipart/form-data': { + type: 'object', + properties: { + file: { + type: 'string', + format: 'binary', + }, + }, + required: ['file'], + }, + }, + }, + responses: { + 200: { + description: 'Users uploaded successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 422: { + description: 'Invalid file format or failed to upload users.', + content: { + 'text/plain': { + type: 'string', + example: 'Wrong format', + }, + }, + }, + }, +}); + +export +{ + uploadUsersRoute +} \ No newline at end of file diff --git a/src/documentation/user-achievementsDescriber.ts b/src/documentation/user-achievementsDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..7a93fff25d30bdb9b08656917e4e30c9ac0a8c4a --- /dev/null +++ b/src/documentation/user-achievementsDescriber.ts @@ -0,0 +1,309 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota POST /associate (associar conquistas a um usuário) + const associateUserAchievementsRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate achievements with a user.', + tags: ['User-Achievements'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + userId: { type: 'integer', description: 'ID of the user' }, + achievementIds: { + type: 'array', + items: { type: 'integer' }, + description: 'List of achievement IDs to be associated with the user' + }, + }, + required: ['userId', 'achievementIds'], + }, + }, + }, + responses: { + 200: { + description: 'Achievements associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate achievements.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /:userId/delete/achievement/:achievementId (remover uma conquista de um usuário) + const removeUserAchievementRoute = describeRoute({ + method: 'POST', + path: '/:userId/delete/achievement/:achievementId', + description: 'Remove an achievement from a user.', + tags: ['User-Achievements'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + { + name: 'achievementId', + in: 'path', + description: 'ID of the achievement', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Achievement removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove achievement.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /update (atualizar conquistas de um usuário) + const updateUserAchievementsRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update achievements for a user.', + tags: ['User-Achievements'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + userId: { type: 'integer', description: 'ID of the user' }, + achievementIds: { + type: 'array', + items: { type: 'integer' }, + description: 'Updated list of achievement IDs for the user' + }, + }, + required: ['userId', 'achievementIds'], + }, + }, + }, + responses: { + 200: { + description: 'Achievements updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to update achievements.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /:userId/achievements (obter conquistas de um usuário) + const getUserAchievementsRoute = describeRoute({ + method: 'GET', + path: '/:userId/achievements', + description: 'Get all achievements of a user.', + tags: ['User-Achievements'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'User achievements retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + achievements: { type: 'array', items: { type: 'object' } }, + }, + }, + }, + }, + 400: { + description: 'Failed to retrieve user achievements.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /:userId/achievements/:achievementId/exists (verificar se uma conquista está associada a um usuário) + const checkUserAchievementExistenceRoute = describeRoute({ + method: 'GET', + path: '/:userId/achievements/:achievementId/exists', + description: 'Check if an achievement is associated with a user.', + tags: ['User-Achievements'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + { + name: 'achievementId', + in: 'path', + description: 'ID of the achievement', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Existence check successful.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check if the association exists.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /achievements/:achievementId/users (obter usuários associados a uma conquista) + const getUsersByAchievementRoute = describeRoute({ + method: 'GET', + path: '/achievements/:achievementId/users', + description: 'Get users who have a specific achievement.', + tags: ['User-Achievements'], + parameters: [ + { + name: 'achievementId', + in: 'path', + description: 'ID of the achievement', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Users associated with the achievement retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + users: { type: 'array', items: { type: 'object' } }, + }, + }, + }, + }, + 400: { + description: 'Failed to retrieve users by achievement.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + associateUserAchievementsRoute, + removeUserAchievementRoute, + updateUserAchievementsRoute, + getUserAchievementsRoute, + checkUserAchievementExistenceRoute, + getUsersByAchievementRoute +} \ No newline at end of file diff --git a/src/documentation/user-collectionDescriber.ts b/src/documentation/user-collectionDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0ffc6cc0d858d0e6019029681cc18ed9b6cab5f --- /dev/null +++ b/src/documentation/user-collectionDescriber.ts @@ -0,0 +1,254 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota POST /associate (associar coleções a um usuário) + const associateUserCollectionsRoute = describeRoute({ + method: 'POST', + path: '/associate', + description: 'Associate collections with a user.', + tags: ['User-Collection'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + userId: { type: 'integer', description: 'ID of the user' }, + collectionIds: { + type: 'array', + items: { type: 'integer' }, + description: 'List of collection IDs to be associated with the user' + }, + }, + required: ['userId', 'collectionIds'], + }, + }, + }, + responses: { + 200: { + description: 'Collections associated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to associate collections.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /:userId/delete/:collectionId (remover coleção de um usuário) + const removeUserCollectionRoute = describeRoute({ + method: 'POST', + path: '/:userId/delete/:collectionId', + description: 'Remove a collection from a user.', + tags: ['User-Collection'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + { + name: 'collectionId', + in: 'path', + description: 'ID of the collection', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Collection removed successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + message: { type: 'string' }, + }, + }, + }, + }, + 400: { + description: 'Failed to remove collection.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /:userId/collections (obter coleções de um usuário) + const getUserCollectionsRoute = describeRoute({ + method: 'GET', + path: '/:userId/collections', + description: 'Get all collections of a user.', + tags: ['User-Collection'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'User collections retrieved successfully.', + content: { + 'application/json': { + type: 'array', + items: { type: 'object' }, + }, + }, + }, + 400: { + description: 'Failed to retrieve user collections.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /:userId/collections/:collectionId/exists (verificar se uma coleção está associada a um usuário) + const checkUserCollectionExistenceRoute = describeRoute({ + method: 'GET', + path: '/:userId/collections/:collectionId/exists', + description: 'Check if a collection is associated with a user.', + tags: ['User-Collection'], + parameters: [ + { + name: 'userId', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + { + name: 'collectionId', + in: 'path', + description: 'ID of the collection', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Existence check successful.', + content: { + 'application/json': { + type: 'object', + properties: { + exists: { type: 'boolean' }, + }, + }, + }, + }, + 400: { + description: 'Failed to check if the association exists.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /collection/:collectionId/users (obter usuários associados a uma coleção) + const getUsersByCollectionRoute = describeRoute({ + method: 'GET', + path: '/collection/:collectionId/users', + description: 'Get users who have a specific collection.', + tags: ['User-Collection'], + parameters: [ + { + name: 'collectionId', + in: 'path', + description: 'ID of the collection', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Users associated with the collection retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + users: { type: 'array', items: { type: 'object' } }, + }, + }, + }, + }, + 400: { + description: 'Failed to retrieve users by collection.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + associateUserCollectionsRoute, + removeUserCollectionRoute, + getUserCollectionsRoute, + checkUserCollectionExistenceRoute, + getUsersByCollectionRoute +} \ No newline at end of file diff --git a/src/documentation/user-institutionDescribers.ts b/src/documentation/user-institutionDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..70d5dbc5d29cf9874468ca4cc67c05b13cee4532 --- /dev/null +++ b/src/documentation/user-institutionDescribers.ts @@ -0,0 +1,201 @@ +import { describeRoute } from 'hono-openapi'; + +// Descrição da rota POST /assign (atribuir instituição a um usuário) + const assignUserToInstitutionRoute = describeRoute({ + method: 'POST', + path: '/assign', + description: 'Assign an institution to a user.', + tags: ['User-Institution'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user to be assigned to an institution' }, + institution_id: { type: 'integer', description: 'ID of the institution to assign' }, + }, + required: ['user_id', 'institution_id'], + }, + }, + }, + responses: { + 200: { + description: 'User successfully assigned to the institution.', + content: { + 'application/json': { + type: 'object', + properties: { + user_institution: { type: 'object' }, // Replace with actual schema for user institution relation + }, + }, + }, + }, + 400: { + description: 'Failed to assign user to institution.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /institutions/user/:user_id (obter instituições de um usuário) + const getUserInstitutionsRoute = describeRoute({ + method: 'GET', + path: '/institutions/user/:user_id', + description: 'Get all institutions assigned to a user.', + tags: ['User-Institution'], + parameters: [ + { + name: 'user_id', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Institutions retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + institutions: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for institutions + }, + }, + }, + }, + }, + 404: { + description: 'User not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /users/institution/:institution_id (obter usuários de uma instituição) + const getInstitutionUsersRoute = describeRoute({ + method: 'GET', + path: '/users/institution/:institution_id', + description: 'Get all users assigned to a specific institution.', + tags: ['User-Institution'], + parameters: [ + { + name: 'institution_id', + in: 'path', + description: 'ID of the institution', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Users retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + users: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for users + }, + }, + }, + }, + }, + 404: { + description: 'Institution not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /revoke (revogar associação de instituição de um usuário) + const revokeUserInstitutionRoute = describeRoute({ + method: 'POST', + path: '/revoke', + description: 'Revoke the association between a user and an institution.', + tags: ['User-Institution'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user to revoke from institution' }, + institution_id: { type: 'integer', description: 'ID of the institution to revoke' }, + }, + required: ['user_id', 'institution_id'], + }, + }, + }, + responses: { + 200: { + description: 'Association successfully revoked.', + content: { + 'application/json': { + type: 'object', + properties: { + user_institution: { type: 'object' }, // Replace with actual schema for user institution relation + }, + }, + }, + }, + 400: { + description: 'Failed to revoke association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + assignUserToInstitutionRoute, + getUserInstitutionsRoute, + getInstitutionUsersRoute, + revokeUserInstitutionRoute +} diff --git a/src/documentation/user-itemDescriber.ts b/src/documentation/user-itemDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc31d06aca672848c41f77f95d9ad0e204007b96 --- /dev/null +++ b/src/documentation/user-itemDescriber.ts @@ -0,0 +1,200 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota POST /create (criar associação entre usuário e item) + const createUserItemAssociationRoute = describeRoute({ + method: 'POST', + path: '/create', + description: 'Create an association between a user and an item.', + tags: ['User-Item'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user' }, + item_id: { type: 'integer', description: 'ID of the item' }, + }, + required: ['user_id', 'item_id'], + }, + }, + }, + responses: { + 200: { + description: 'User-item association created successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_item: { type: 'object' }, // Replace with actual schema for user-item relation + }, + }, + }, + }, + 400: { + description: 'Failed to create user-item association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /items/user/:user_id (obter itens associados a um usuário) + const getItemsByUserRoute = describeRoute({ + method: 'GET', + path: '/items/user/:user_id', + description: 'Get all items associated with a user.', + tags: ['User-Item'], + parameters: [ + { + name: 'user_id', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Items associated with the user retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + items: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for items + }, + }, + }, + }, + }, + 404: { + description: 'User not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /users/item/:item_id (obter usuários associados a um item) + const getUsersByItemRoute = describeRoute({ + method: 'GET', + path: '/users/item/:item_id', + description: 'Get all users associated with a specific item.', + tags: ['User-Item'], + parameters: [ + { + name: 'item_id', + in: 'path', + description: 'ID of the item', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Users associated with the item retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + users: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for users + }, + }, + }, + }, + }, + 404: { + description: 'Item not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota DELETE /delete (remover associação entre usuário e item) + const deleteUserItemAssociationRoute = describeRoute({ + method: 'DELETE', + path: '/delete', + description: 'Delete an association between a user and an item.', + tags: ['User-Item'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user' }, + item_id: { type: 'integer', description: 'ID of the item' }, + }, + required: ['user_id', 'item_id'], + }, + }, + }, + responses: { + 200: { + description: 'User-item association deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_item: { type: 'object' }, // Replace with actual schema for user-item relation + }, + }, + }, + }, + 400: { + description: 'Failed to delete user-item association.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + createUserItemAssociationRoute, + getItemsByUserRoute, + getUsersByItemRoute, + deleteUserItemAssociationRoute +} \ No newline at end of file diff --git a/src/documentation/user-roleDescribers.ts b/src/documentation/user-roleDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..bffafa7e2d1b0e761f821956c676a96bfb16feb6 --- /dev/null +++ b/src/documentation/user-roleDescribers.ts @@ -0,0 +1,201 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota POST /assign (atribuir uma função a um usuário) + const assignUserRoleRoute = describeRoute({ + method: 'POST', + path: '/assign', + description: 'Assign a role to a user.', + tags: ['User-Role'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user' }, + role_id: { type: 'integer', description: 'ID of the role' }, + }, + required: ['user_id', 'role_id'], + }, + }, + }, + responses: { + 200: { + description: 'Role assigned successfully to the user.', + content: { + 'application/json': { + type: 'object', + properties: { + user_role: { type: 'object' }, // Replace with actual schema for user-role relation + }, + }, + }, + }, + 400: { + description: 'Failed to assign role to user.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /roles/user/:user_id (obter funções associadas a um usuário) + const getRolesByUserRoute = describeRoute({ + method: 'GET', + path: '/roles/user/:user_id', + description: 'Get all roles associated with a specific user.', + tags: ['User-Role'], + parameters: [ + { + name: 'user_id', + in: 'path', + description: 'ID of the user', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Roles associated with the user retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + roles: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for roles + }, + }, + }, + }, + }, + 404: { + description: 'User not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /users/role/:role_id (obter usuários associados a uma função) + const getUsersByRoleRoute = describeRoute({ + method: 'GET', + path: '/users/role/:role_id', + description: 'Get all users associated with a specific role.', + tags: ['User-Role'], + parameters: [ + { + name: 'role_id', + in: 'path', + description: 'ID of the role', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'Users associated with the role retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + users: { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for users + }, + }, + }, + }, + }, + 404: { + description: 'Role not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /revoke (revogar função de um usuário) + const revokeUserRoleRoute = describeRoute({ + method: 'POST', + path: '/revoke', + description: 'Revoke a role from a user.', + tags: ['User-Role'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user' }, + role_id: { type: 'integer', description: 'ID of the role' }, + }, + required: ['user_id', 'role_id'], + }, + }, + }, + responses: { + 200: { + description: 'Role revoked successfully from the user.', + content: { + 'application/json': { + type: 'object', + properties: { + user_role: { type: 'object' }, // Replace with actual schema for user-role relation + }, + }, + }, + }, + 400: { + description: 'Failed to revoke role from user.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + + +export +{ + assignUserRoleRoute, + getRolesByUserRoute, + getUsersByRoleRoute, + revokeUserRoleRoute +} \ No newline at end of file diff --git a/src/documentation/user-statsDescribers.ts b/src/documentation/user-statsDescribers.ts new file mode 100644 index 0000000000000000000000000000000000000000..28933a95d415605105b90f5e2e940165c53fe354 --- /dev/null +++ b/src/documentation/user-statsDescribers.ts @@ -0,0 +1,256 @@ +import { describeRoute } from 'hono-openapi'; +// Descrição da rota POST /update (atualiza as estatísticas de um usuário) + const updateUserStatsRoute = describeRoute({ + method: 'POST', + path: '/update', + description: 'Update user statistics.', + tags: ['User-Stats'], + requestBody: { + content: { + 'application/json': { + type: 'object', + properties: { + user_id: { type: 'integer', description: 'ID of the user' }, + // Include other fields relevant for updating user stats + }, + required: ['user_id'], // Add any required fields based on your schema + }, + }, + }, + responses: { + 200: { + description: 'User statistics updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_stats: { type: 'object' }, // Replace with actual schema for user stats + }, + }, + }, + }, + 400: { + description: 'Failed to update user statistics.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /delete/:id (deleta as estatísticas de um usuário) + const deleteUserStatsRoute = describeRoute({ + method: 'POST', + path: '/delete/:id', + description: 'Delete user statistics by ID.', + tags: ['User-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + description: 'ID of the user statistics to delete', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'User statistics deleted successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_stats: { type: 'object' }, // Replace with actual schema for user stats + }, + }, + }, + }, + 400: { + description: 'Failed to delete user statistics.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + 404: { + description: 'User statistics not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota POST /updateComments/:id (atualiza os comentários de um usuário) + const updateUserStatsCommentsRoute = describeRoute({ + method: 'POST', + path: '/updateComments/:id', + description: 'Update user statistics comments.', + tags: ['User-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + description: 'ID of the user statistics to update comments', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'User statistics comments updated successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_stats: { type: 'object' }, // Replace with actual schema for user stats + }, + }, + }, + }, + 400: { + description: 'Failed to update user statistics comments.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /all (obtém todas as estatísticas de usuários) + const getAllUserStatsRoute = describeRoute({ + method: 'GET', + path: '/all', + description: 'Get all user statistics.', + tags: ['User-Stats'], + responses: { + 200: { + description: 'All user statistics retrieved successfully.', + content: { + 'application/json': { + type: 'array', + items: { type: 'object' }, // Replace with actual schema for user stats + }, + }, + }, + 400: { + description: 'Failed to retrieve user statistics.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +// Descrição da rota GET /:id (obtém estatísticas de um usuário específico) + const getUserStatsByIdRoute = describeRoute({ + method: 'GET', + path: '/:id', + description: 'Get specific user statistics by ID.', + tags: ['User-Stats'], + parameters: [ + { + name: 'id', + in: 'path', + description: 'ID of the user statistics to fetch', + required: true, + schema: { type: 'integer' }, + }, + ], + responses: { + 200: { + description: 'User statistics retrieved successfully.', + content: { + 'application/json': { + type: 'object', + properties: { + user_stats: { type: 'object' }, // Replace with actual schema for user stats + }, + }, + }, + }, + 400: { + description: 'Failed to fetch user statistics.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + 404: { + description: 'User statistics not found.', + content: { + 'application/json': { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + message: { type: 'string' }, + code: { type: 'integer' }, + path: { type: 'string' }, + suggestion: { type: 'string' }, + }, + }, + }, + }, + }, +}); + +export +{ + updateUserStatsRoute, + deleteUserStatsRoute, + updateUserStatsCommentsRoute, + getAllUserStatsRoute, + getUserStatsByIdRoute +} \ No newline at end of file diff --git a/src/documentation/userDescriber.ts b/src/documentation/userDescriber.ts new file mode 100644 index 0000000000000000000000000000000000000000..b362d17f66f760d5862510c9ff496277d906e753 --- /dev/null +++ b/src/documentation/userDescriber.ts @@ -0,0 +1,322 @@ +import { describeRoute } from 'hono-openapi'; + + +const followUserRoute = describeRoute({ + method: "POST", + path: "/follow", + summary: "Seguir um usuário.", + description: "Cria uma relação de seguidor entre dois usuários, aumentando o número de seguidores e seguidos.", + request: { + body: { + type: "object", + properties: { + follower_id: { type: "number", description: "ID do usuário que está seguindo." }, + user_id: { type: "number", description: "ID do usuário que está sendo seguido." } + }, + required: ["follower_id", "user_id"] + } + }, + response: { + 200: { + description: "Usuário seguido com sucesso.", + content: { + "application/json": { + followRelation: { + type: "object", + properties: { + id: { type: "number" }, + follower_id: { type: "number" }, + user_id: { type: "number" } + } + } + } + } + }, + 400: { description: "Erro ao seguir usuário." } + } + }); + + const unfollowUserRoute = describeRoute({ + method: "POST", + path: "/unfollow", + summary: "Deixar de seguir um usuário.", + description: "Remove a relação de seguidor entre dois usuários, reduzindo o número de seguidores e seguidos.", + request: { + body: { + type: "object", + properties: { + follower_id: { type: "number", description: "ID do usuário que está deixando de seguir." }, + user_id: { type: "number", description: "ID do usuário que está sendo deixado de seguir." } + }, + required: ["follower_id", "user_id"] + } + }, + response: { + 200: { + description: "Usuário deixou de ser seguido com sucesso.", + content: { + "application/json": { + followRelation: { + type: "object", + properties: { + id: { type: "number" }, + follower_id: { type: "number" }, + user_id: { type: "number" } + } + } + } + } + }, + 400: { description: "Erro ao deixar de seguir usuário." } + } + }); + + const getFollowsRoute = describeRoute({ + method: "GET", + path: "/follows/:id", + summary: "Listar usuários seguidos.", + description: "Retorna a lista de usuários que o ID especificado segue.", + request: { + params: { + id: { type: "number", description: "ID do usuário." } + } + }, + response: { + 200: { + description: "Lista de usuários seguidos.", + content: { + "application/json": { + follows: { + type: "array", + items: { type: "object" } + } + } + } + }, + 404: { description: "Usuário não encontrado." } + } + }); + + const getFollowersRoute = describeRoute({ + method: "GET", + path: "/followers/:id", + summary: "Listar seguidores.", + description: "Retorna a lista de usuários que seguem o ID especificado.", + request: { + params: { + id: { type: "number", description: "ID do usuário." } + } + }, + response: { + 200: { + description: "Lista de seguidores.", + content: { + "application/json": { + followers: { + type: "array", + items: { type: "object" } + } + } + } + }, + 404: { description: "Usuário não encontrado." } + } + }); + + const getUsersRoute = describeRoute({ + method: "GET", + path: "/users", + summary: "Listar todos os usuários.", + description: "Retorna a lista de todos os usuários cadastrados.", + response: { + 200: { + description: "Lista de usuários.", + content: { + "application/json": { + users: { + type: "array", + items: { type: "object" } + } + } + } + } + } + }); + + const getUserByUsernameRoute = describeRoute({ + method: "GET", + path: "/:username", + summary: "Obter detalhes de um usuário pelo nome de usuário.", + description: "Retorna as informações de um usuário com base no seu nome de usuário.", + request: { + params: { + username: { type: "string", description: "Nome de usuário." } + } + }, + response: { + 200: { + description: "Usuário encontrado.", + content: { + "application/json": { + user: { type: "object" } + } + } + }, + 404: { description: "Usuário não encontrado." } + } + }); + + +const updateUserRoute = describeRoute({ + method: "POST", + path: "/update", + summary: "Atualiza as informações de um usuário.", + description: "Recebe os novos dados do usuário e atualiza no banco de dados.", + request: { + body: { + type: "object", + properties: { + id: { type: "number", description: "ID do usuário a ser atualizado." }, + name: { type: "string", description: "Novo nome do usuário." }, + email: { type: "string", description: "Novo e-mail do usuário." }, + password: { type: "string", description: "Nova senha do usuário." } + }, + required: ["id"] + } + }, + response: { + 200: { + description: "Usuário atualizado com sucesso.", + content: { + "application/json": { + user: { + type: "object", + properties: { + id: { type: "number" }, + name: { type: "string" }, + email: { type: "string" }, + updated_at: { type: "string", description: "Data da última atualização." } + } + } + } + } + }, + 400: { description: "Erro ao atualizar usuário." } + } + }); + + const confirmUserRoute = describeRoute({ + method: "POST", + path: "/confirmation/:email", + summary: "Confirma o e-mail do usuário.", + description: "Atualiza o status de confirmação do usuário baseado no e-mail informado.", + request: { + params: { + email: { type: "string", description: "E-mail do usuário a ser confirmado." } + } + }, + response: { + 200: { + description: "Usuário confirmado com sucesso.", + content: { + "application/json": { + id: { type: "number" }, + email: { type: "string" }, + confirmed_at: { type: "string", description: "Data de confirmação do e-mail." } + } + } + }, + 400: { description: "Erro ao confirmar usuário." } + } + }); + + const reactivateUserRoute = describeRoute({ + method: "POST", + path: "/reactivate/:email", + summary: "Reativa um usuário inativo.", + description: "Altera o status do usuário para ativo e atualiza a data de reativação.", + request: { + params: { + email: { type: "string", description: "E-mail do usuário a ser reativado." } + } + }, + response: { + 200: { + description: "Usuário reativado com sucesso.", + content: { + "application/json": { + id: { type: "number" }, + email: { type: "string" }, + active: { type: "boolean", description: "Status de atividade do usuário." }, + reactivated_at: { type: "string", description: "Data da reativação." } + } + } + }, + 400: { description: "Erro ao reativar usuário." } + } + }); + + const deleteUserRoute = describeRoute({ + method: "POST", + path: "/delete/:id", + summary: "Desativa um usuário.", + description: "Marca um usuário como inativo e registra a data de exclusão.", + request: { + params: { + id: { type: "number", description: "ID do usuário a ser desativado." } + } + }, + response: { + 200: { + description: "Usuário desativado com sucesso.", + content: { + "application/json": { + id: { type: "number" }, + active: { type: "boolean", description: "Status de atividade do usuário (falso)." }, + deleted_at: { type: "string", description: "Data da desativação." } + } + } + }, + 400: { description: "Erro ao desativar usuário." } + } + }); + + const systemDeleteUserRoute = describeRoute({ + method: "POST", + path: "/delete/system/:id", + summary: "Exclui um usuário permanentemente.", + description: "Remove um usuário do banco de dados de forma definitiva.", + request: { + params: { + id: { type: "number", description: "ID do usuário a ser removido permanentemente." } + } + }, + response: { + 200: { + description: "Usuário excluído permanentemente.", + content: { + "application/json": { + id: { type: "number" }, + deleted: { type: "boolean", description: "Confirmação da exclusão." } + } + } + }, + 400: { description: "Erro ao excluir usuário." } + } + }); + + +export +{ + followUserRoute, + unfollowUserRoute, + getFollowsRoute, + getFollowersRoute, + getUsersRoute, + getUserByUsernameRoute, + updateUserRoute, + confirmUserRoute, + reactivateUserRoute, + deleteUserRoute, + systemDeleteUserRoute +} \ No newline at end of file diff --git a/src/documentation/userDescribers.ts b/src/documentation/userDescribers.ts deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/routes/comment-reply.route.ts b/src/routes/comment-reply.route.ts index fc67c8b753f980ed8cca7656c488812573aff49b..18eb3e77704eb13bb675f24bceb163789860f324 100644 --- a/src/routes/comment-reply.route.ts +++ b/src/routes/comment-reply.route.ts @@ -8,6 +8,15 @@ import { Hono } from "hono"; import { UserStatsService } from "@/services/user-stats.service"; import { ResourceStatsService } from "@/services/resource-stats.service"; import { CommentsService } from "@/services/comments.sevice"; +import{ + createCommentReplyRouteDescription, + updateCommentReplyRouteDescription, + deleteDataCommentReplyRouteDescription, + deleteCommentReplyRouteDescription, + findReplyByCommentRouteDescription, + findAllReplyByCommentRouteDescription, + findAllReplyByUserRouteDescription +} from "../documentation/comment-replyDescribers" const service = Container.get(CommentReplyService) const serviceUserStats = Container.get(UserStatsService) @@ -16,7 +25,7 @@ const serviceComment = Container.get(CommentsService) export const commentReplyRouter = honoWithJwt() - .post('/create', + .post('/create', createCommentReplyRouteDescription, zValidator('json', commentReplySchema.input), async (c) => { try { @@ -49,7 +58,7 @@ export const commentReplyRouter = honoWithJwt() ) - .post('/update', + .post('/update', updateCommentReplyRouteDescription, zValidator('json', commentReplySchema.update), async (c) => { try { @@ -71,7 +80,7 @@ export const commentReplyRouter = honoWithJwt() } ) - .post('deleteData/:id', + .post('deleteData/:id', deleteDataCommentReplyRouteDescription, async (c) => { try { const id = +c.req.param('id') @@ -94,7 +103,7 @@ export const commentReplyRouter = honoWithJwt() } ) - .post('delete/:id', + .post('delete/:id', deleteCommentReplyRouteDescription, async (c) => { try { const id = +c.req.param('id') @@ -119,7 +128,7 @@ export const commentReplyRouter = honoWithJwt() export const publicCommentsReplyRoute = new Hono() // get active reply by comment - .get('/findReplyByComment/:comment_id', async (c) => { + .get('/findReplyByComment/:comment_id', findReplyByCommentRouteDescription, async (c) => { try { const id_comment = +c.req.param('comment_id') const comments = commentReplySchema.dto.array().parse(await service.findReplyByComment(id_comment)); @@ -140,7 +149,7 @@ export const publicCommentsReplyRoute = new Hono() }) // get all reply by comment - .get('/findAllReplyByComment/:comment_id', async (c) => { + .get('/findAllReplyByComment/:comment_id', findAllReplyByCommentRouteDescription, async (c) => { try { const id_comment = +c.req.param('comment_id') const comments = commentReplySchema.dto.array().parse(await service.findAllReplyByComment(id_comment)); @@ -161,7 +170,7 @@ export const publicCommentsReplyRoute = new Hono() }) // get all reply by user - .get('/findAllReplyByUser/:id_user', async (c) => { + .get('/findAllReplyByUser/:id_user', findAllReplyByUserRouteDescription, async (c) => { try { const id_user = +c.req.param('id_user') const comments = commentReplySchema.dto.array().parse(await service.findAllReplyByUser(id_user));