"use strict";async function getMarket(e){const r=await db_1.models.exchangeMarket.findOne({where:{id:e}});if(!r)throw(0,error_1.createError)({statusCode:404,message:"Market not found"});return r.get({plain:!0})}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getMarket=getMarket;const redis_1=require("@b/utils/redis"),db_1=require("@b/db"),console_1=require("@b/utils/console"),error_1=require("@b/utils/error"),redis=redis_1.RedisSingleton.getInstance(),query_1=require("@b/utils/query"),utils_1=require("../utils");exports.metadata={summary:"Show Market Details",operationId:"showMarket",tags:["Exchange","Markets"],description:"Retrieves details of a specific market by ID.",logModule:"EXCHANGE",logTitle:"Get Market Details",parameters:[{name:"id",in:"path",required:!0,description:"The ID of the market to retrieve.",schema:{type:"string"}}],responses:{200:{description:"Market details",content:{"application/json":{schema:{type:"object",properties:utils_1.baseMarketSchema}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Market"),500:query_1.serverErrorResponse}};exports.default=async e=>{const{params:r,ctx:t}=e,{id:s}=r;null==t||t.step(`Fetching market ${s}`);try{const e=await redis.get("exchangeMarkets");if(e){const r=JSON.parse(e).find(e=>e.id===s);if(r){null==t||t.success("Market retrieved from cache");return r}}}catch(e){console_1.logger.error("EXCHANGE","Redis error",e)}const a=await getMarket(s);null==t||t.success("Market retrieved successfully");return a};