const { asyncHandler } = require("../middleware/errorHandler");
const ApiResponse = require("../utils/apiResponse");
const CryptoService = require("../services/cryptoService");

exports.getCryptoData = asyncHandler(async (req, res) => {
    
    const cryptoData = await CryptoService.getCryptoData();
    return ApiResponse.success(res, { message: 'Crypto data endpoint', data: cryptoData })
})

exports.updateCryptoData = asyncHandler(async (req, res) => {
    
    const cryptoData = await CryptoService.updateCryptoAssets();
    return ApiResponse.success(res, { message: 'Crypto data updated', data: cryptoData })
})

exports.updateCryptoMarketStats = asyncHandler(async (req, res) => {
    
    const cryptoData = await CryptoService.updateMarketStat();
    return ApiResponse.success(res, { message: 'Crypto market stats updated', data: cryptoData })
})