"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.statsRoute = void 0;
const express_1 = __importDefault(require("express"));
const logger_1 = __importDefault(require("../../logger"));
const chain_state_1 = require("../../providers/chain-state");
const middleware_1 = require("../middleware");
const router = express_1.default.Router({ mergeParams: true });
router.get('/', async function (_, res) {
    return res.send(404);
});
router.get('/daily-transactions', async function (req, res) {
    const { chain, network } = req.params;
    try {
        const dailyTxs = await chain_state_1.ChainStateProvider.getDailyTransactions({
            chain,
            network,
            startDate: req.query.startDate,
            endDate: req.query.endDate
        });
        (0, middleware_1.SetCache)(res, middleware_1.CacheTimes.Day);
        return res.json(dailyTxs);
    }
    catch (err) {
        logger_1.default.error('Error getting daily transactions: %o', err.stack || err.message || err);
        return res.status(500).send(err.message || err);
    }
});
exports.statsRoute = {
    router,
    path: '/stats'
};
//# sourceMappingURL=stats.js.map