import { Router } from "express";
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
import { restrictToHosts } from "../../../../pkg/middleware/restrictToHosts.js";
import addServer from "./addServer.js";
import getServers from "./getServers.js";
import updateServer from "./updateServer.js";

const router = Router();

router.use("/", getServers);
router.use(
	"/",
	requireAuth("user", ["systemAdmin", "admin"]),
	restrictToHosts([
		"localhost:5500",
		"usmcd1vms036.alpla.net",
		"USMCD1VMS036.alpla.net",
		"https://usmcd1vms036.alpla.net",
	]),
	addServer,
);
router.use(
	"/",
	requireAuth("user", ["systemAdmin", "admin"]),
	restrictToHosts([
		"localhost:5500",
		"usmcd1vms036.alpla.net",
		"USMCD1VMS036.alpla.net",
		"https://usmcd1vms036.alpla.net",
	]),
	updateServer,
);

export default router;
