"use strict";async function getCategory(e,t){const s=t?[{model:db_1.models.post,as:"posts",include:[{model:db_1.models.author,as:"author",include:[{model:db_1.models.user,as:"user",attributes:["id","firstName","lastName","email","avatar"]}]}]}]:[];return await db_1.models.category.findOne({where:{slug:e},include:s}).then(e=>e?e.get({plain:!0}):null)}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getCategory=getCategory;const db_1=require("@b/db"),query_1=require("@b/utils/query"),utils_1=require("../utils");exports.metadata={summary:"Retrieves a single category by ID with optional inclusion of posts",description:"This endpoint retrieves a single category by its ID with optional inclusion of posts.",operationId:"getCategoryById",tags:["Blog"],requiresAuth:!1,parameters:[{index:0,name:"slug",in:"path",description:"The ID of the category to retrieve",required:!0,schema:{type:"string",description:"Category ID"}},{name:"posts",in:"query",description:"Include posts in the category",required:!1,schema:{type:"boolean"}}],responses:{200:{description:"Category retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{...utils_1.baseCategorySchema,posts:utils_1.categoryPostsSchema}}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Category"),500:query_1.serverErrorResponse}};exports.default=async e=>getCategory(e.params.slug,"true"===e.query.posts);