"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTokenRoutes = void 0;
const express_1 = require("express");
const validation_middleware_1 = require("../middleware/validation.middleware");
const dto_1 = require("../../application/dto");
/**
 * Token routes mounted under `/api/v1`.
 *
 * Routes:
 *  - GET /tokens                        List all tokens with pagination.
 *                                         Query: { limit?: number, offset?: number }
 *  - GET /tokens/by-symbol/:symbol      Get a token by its symbol.
 *                                         Param: { symbol: string }
 *  - GET /tokens/prices                 Get current prices for requested symbols.
 *                                         Query: { symbols: string }
 *  - GET /tokens/:id                    Get a token by its UUID.
 *                                         Param: { id: string (UUID) }
 *  - GET /networks/:networkId/tokens    List tokens belonging to a network.
 *                                         Param: { networkId: string (UUID) }
 *  - GET /tokens/:id/chart              Get price history chart for a token.
 *                                         Param: { id: string (UUID) }
 *                                         Query: { timeframe?: string }
 *  - POST /tokens/lookup                Resolve or create a token by chain id and optional contract address.
 *                                         Body: { chainId: number, contractAddress?: string | null }
 *                                         If contractAddress is omitted, returns the network's native token.
 *                                         Response: { token, network }
 */
const createTokenRoutes = (controller) => {
    const router = (0, express_1.Router)();
    router.get('/tokens', (0, validation_middleware_1.validateRequest)({ query: dto_1.paginationQuerySchema }), controller.getAll);
    // Static token routes must be registered before `/tokens/:id` so they are not
    // matched as a UUID parameter.
    router.get('/tokens/by-symbol/:symbol', (0, validation_middleware_1.validateRequest)({ params: dto_1.tokenSymbolParamSchema }), controller.getBySymbol);
    router.get('/tokens/prices', (0, validation_middleware_1.validateRequest)({ query: dto_1.tokenPricesQuerySchema }), controller.getPrices);
    router.post('/tokens/lookup', (0, validation_middleware_1.validateRequest)({ body: dto_1.tokenLookupSchema }), controller.lookupByContract);
    router.get('/tokens/:id', (0, validation_middleware_1.validateRequest)({ params: dto_1.tokenIdParamSchema }), controller.getById);
    router.get('/networks/:networkId/tokens', (0, validation_middleware_1.validateRequest)({ params: dto_1.networkIdParamSchema }), controller.getByNetwork);
    router.get('/tokens/:id/chart', (0, validation_middleware_1.validateRequest)({ params: dto_1.tokenIdParamSchema }), controller.getChart);
    return router;
};
exports.createTokenRoutes = createTokenRoutes;
//# sourceMappingURL=token.routes.js.map