"use strict";

const router = require("express").Router();
const { authenticateAdmin, audit } = require("../../middleware");

const AdminNetworksController = require("../../controllers/admin/networksController");

/**
 * Networks
 */
router.get("/networks", authenticateAdmin, AdminNetworksController.listNetworks);
router.post("/networks", authenticateAdmin, audit("networks.create", "network"), AdminNetworksController.createNetwork);
router.get("/networks/:id", authenticateAdmin, AdminNetworksController.getNetworkById);
router.put("/networks/:id", authenticateAdmin, audit("networks.update", "network"), AdminNetworksController.updateNetwork);
router.delete("/networks/:id", authenticateAdmin, audit("networks.delete", "network"), AdminNetworksController.deleteNetwork);

/**
 * Network Addresses
 */
router.get("/network-addresses", authenticateAdmin, AdminNetworksController.listNetworkAddresses);
router.post("/network-addresses", authenticateAdmin, audit("network_addresses.create", "network_address"), AdminNetworksController.createNetworkAddress);
router.get("/network-addresses/:id", authenticateAdmin, AdminNetworksController.getNetworkAddressById);
router.put("/network-addresses/:id", authenticateAdmin, audit("network_addresses.update", "network_address"), AdminNetworksController.updateNetworkAddress);
router.delete("/network-addresses/:id", authenticateAdmin, audit("network_addresses.delete", "network_address"), AdminNetworksController.deleteNetworkAddress);

/**
 * Coin Networks
 */
router.get("/coin-networks", authenticateAdmin, AdminNetworksController.listCoinNetworks);
router.post("/coin-networks", authenticateAdmin, audit("coin_networks.create", "coin_network"), AdminNetworksController.createCoinNetwork);
router.get("/coin-networks/:id", authenticateAdmin, AdminNetworksController.getCoinNetworkById);
router.put("/coin-networks/:id", authenticateAdmin, audit("coin_networks.update", "coin_network"), AdminNetworksController.updateCoinNetwork);
router.delete("/coin-networks/:id", authenticateAdmin, audit("coin_networks.delete", "coin_network"), AdminNetworksController.deleteCoinNetwork);

module.exports = router;