"use strict";async function getTag(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"]}]},{model:db_1.models.category,as:"category"}]}]:[];return await db_1.models.tag.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.getTag=getTag;const db_1=require("@b/db"),query_1=require("@b/utils/query"),utils_1=require("../utils");exports.metadata={summary:"Retrieves a single tag by slug with optional inclusion of posts",description:"This endpoint retrieves a single tag by its slug with optional inclusion of posts.",operationId:"getTagBySlug",tags:["Blog"],requiresAuth:!1,parameters:[{index:0,name:"slug",in:"path",description:"The slug of the tag to retrieve",required:!0,schema:{type:"string"}},{name:"posts",in:"query",description:"Include posts tagged with this tag",required:!1,schema:{type:"boolean"}}],responses:{200:{description:"Tag retrieved successfully",content:{"application/json":{schema:{type:"object",properties:{...utils_1.baseTagSchema,posts:utils_1.tagPostsSchema}}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Tag"),500:query_1.serverErrorResponse}};exports.default=async e=>{const{params:t,query:s,ctx:a}=e;null==a||a.step(`Fetching tag ${t.slug}`);const r=await getTag(t.slug,"true"===s.posts);null==a||a.success("Tag retrieved successfully");return r};