import { Router } from 'express';
import { NetworkController } from '../controllers/network.controller';
import { validateRequest } from '../middleware/validation.middleware';
import { networkGasParamsSchema } from '../../application/dto/network-gas.dto';

/**
 * Network routes mounted under `/api/v1`.
 *
 * Routes:
 *  - GET /networks               List all active networks (public, cached).
 *  - GET /networks/:networkId/gas  Current block, gas price, gas limit and fee for a network.
 */
export const createNetworkRoutes = (controller: NetworkController): Router => {
  const router = Router();

  router.get('/networks', controller.getAll);

  router.get(
    '/networks/:networkId/gas',
    validateRequest({ params: networkGasParamsSchema }),
    controller.getGasInfo,
  );

  return router;
};
