"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;const error_1=require("@b/utils/error"),db_1=require("@b/db"),query_1=require("@b/utils/query");exports.metadata={summary:"Retrieve author with his posts",description:"This endpoint retrieves the author profile associated with a given user id along with the posts linked to that profile.",operationId:"getAuthorWithPosts",tags:["Content","Author"],requiresAuth:!0,parameters:[{in:"path",name:"id",required:!0,schema:{type:"string"},description:"Author ID"}],responses:{200:{description:"Author and posts retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{author:{type:"object"},posts:{type:"array",items:{type:"object"}}}}}}},404:(0,query_1.notFoundMetadataResponse)("Author"),500:query_1.serverErrorResponse}};exports.default=async e=>{const{params:t}=e,{id:r}=t,s=await db_1.models.author.findByPk(r,{include:[{model:db_1.models.post,as:"posts",include:[{model:db_1.models.category,as:"category"}]},{model:db_1.models.user,as:"user",attributes:["id","firstName","lastName","profile","avatar"]}]});if(!s)throw(0,error_1.createError)({statusCode:404,message:"Author not found"});return s};