"use strict";async function getCurrency(e){const r=await db_1.models.exchangeCurrency.findOne({where:{id:e,status:!0}});if(!r)throw(0,error_1.createError)({statusCode:404,message:"Currency not found"});return r.get({plain:!0})}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getCurrency=getCurrency;const db_1=require("@b/db"),redis_1=require("@b/utils/redis"),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 Currency",operationId:"getCurrency",tags:["Currencies"],description:"Retrieves details of a specific currency by ID.",logModule:"EXCHANGE",logTitle:"Get Currency Details",parameters:[{name:"id",in:"path",description:"ID of the currency to retrieve.",required:!0,schema:{type:"string"}}],responses:{200:{description:"Currency details",content:{"application/json":{schema:{type:"object",properties:utils_1.baseCurrencySchema}}}},401:query_1.unauthorizedResponse,404:(0,query_1.notFoundMetadataResponse)("Currency"),500:query_1.serverErrorResponse}};exports.default=async e=>{const{params:r,ctx:t}=e,{id:s}=r;null==t||t.step(`Fetching currency ${s}`);try{const e=await redis.get("exchangeCurrencies");if(e){const r=JSON.parse(e).find(e=>e.id===Number(s));if(r){null==t||t.success("Currency retrieved from cache");return r}}}catch(e){console_1.logger.error("EXCHANGE","Redis error",e)}const n=await getCurrency(Number(s));null==t||t.success("Currency retrieved successfully");return n};