"use strict";async function getCurrencies(){return(await db_1.models.exchangeCurrency.findAll({where:{status:!0}})).map(e=>e.get({plain:!0}))}Object.defineProperty(exports,"__esModule",{value:!0});exports.metadata=void 0;exports.getCurrencies=getCurrencies;const db_1=require("@b/db"),redis_1=require("@b/utils/redis"),console_1=require("@b/utils/console"),redis=redis_1.RedisSingleton.getInstance(),query_1=require("@b/utils/query"),utils_1=require("./utils");exports.metadata={summary:"List Currencies",operationId:"getCurrencies",tags:["Currencies"],description:"Retrieves a list of all currencies.",logModule:"EXCHANGE",logTitle:"Get Currencies",responses:{200:{description:"A list of currencies",content:{"application/json":{schema:{type:"array",items:{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{ctx:r}=e;null==r||r.step("Retrieving currencies from cache");try{const e=await redis.get("exchangeCurrencies");if(e){const s=JSON.parse(e);null==r||r.success(`Retrieved ${s.length} currencies from cache`);return s}}catch(e){console_1.logger.error("EXCHANGE","Redis error",e)}null==r||r.step("Fetching currencies from database");const s=await getCurrencies();null==r||r.success(`Retrieved ${s.length} currencies`);return s};