"use strict";async function getAuthors(e,t){const s=[{model:db_1.models.user,as:"user",attributes:["id","firstName","lastName","email","avatar","profile"]}];e&&s.push({model:db_1.models.post,as:"post"});const r={};t&&(r.status=t);return(await db_1.models.author.findAll({where:r,include:s})).map(e=>e.get({plain:!0}))}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getAuthors=getAuthors;const db_1=require("@b/db"),utils_1=require("./utils"),query_1=require("@b/utils/query");exports.metadata={summary:"Lists all authors based on status and posts",description:"This endpoint retrieves all available authors based on their status and optionally includes their posts.",operationId:"getAuthors",tags:["Content","Author"],requiresAuth:!1,parameters:[{name:"status",in:"query",description:"Filter authors by status",required:!1,schema:{type:"string",enum:["PENDING","APPROVED","REJECTED"]}},{name:"posts",in:"query",description:"Include posts for each author",required:!1,schema:{type:"boolean"}}],responses:{200:{description:"Authors retrieved successfully",content:{"application/json":{schema:{type:"array",items:utils_1.baseAuthorSchema}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Author"),500:query_1.serverErrorResponse}};exports.default=async e=>{const{query:t}=e;return getAuthors("true"===t.posts,t.status)};