"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAdminRoutes = void 0;
const express_1 = require("express");
const validation_middleware_1 = require("../middleware/validation.middleware");
const api_key_middleware_1 = require("../middleware/api-key.middleware");
const dto_1 = require("../../application/dto");
/**
 * Admin routes mounted under `/api/v1`.
 *
 * All routes require the `x-api-key` header.
 *
 * Routes:
 *  - POST /admin/networks   Create a network.
 *                           Header: x-api-key
 *                           Body: { name, code, addressType, thumbnail?, explorer, chainId?, status?, mcap? }
 *  - POST /admin/tokens     Create a token.
 *                           Header: x-api-key
 *                           Body: { isNative, address?, networkId, thumbnail?, name, symbol, decimals, code, info?, isActive?, minimumSwapValue? }
 *  - PATCH /admin/tokens/:id  Update a token.
 *                           Header: x-api-key
 *                           Body: { isNative?, address?, networkId?, thumbnail?, name?, symbol?, decimals?, code?, cmcId?, info?, isActive?, minimumSwapValue? }
 *  - DELETE /admin/tokens/:id  Delete a token.
 *                           Header: x-api-key
 *  - PATCH /admin/tokens/:id/minimum-swap-value  Set a custom minimum swap value for a token.
 *                           Header: x-api-key
 *                           Body: { minimumSwapValue: number | null }
 */
const createAdminRoutes = (controller) => {
    const router = (0, express_1.Router)();
    router.post('/admin/networks', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({ body: dto_1.createNetworkSchema }), controller.createNetwork);
    router.post('/admin/tokens', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({ body: dto_1.createTokenSchema }), controller.createToken);
    router.patch('/admin/tokens/:id', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({
        params: dto_1.tokenIdParamSchema,
        body: dto_1.updateTokenSchema,
    }), controller.updateToken);
    router.delete('/admin/tokens/:id', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({
        params: dto_1.tokenIdParamSchema,
    }), controller.deleteToken);
    router.patch('/admin/tokens/:id/minimum-swap-value', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({
        params: dto_1.tokenIdParamSchema,
        body: dto_1.updateTokenMinimumSwapValueSchema,
    }), controller.updateTokenMinimumSwapValue);
    router.post('/admin/tokens/fetch', api_key_middleware_1.apiKeyMiddleware, (0, validation_middleware_1.validateRequest)({ body: dto_1.fetchTokenDataSchema }), controller.fetchTokenData);
    return router;
};
exports.createAdminRoutes = createAdminRoutes;
//# sourceMappingURL=admin.routes.js.map