import type { Express, Request, Response } from "express";
import { requireAuth } from "../../pkg/middleware/authMiddleware.js";
import { mainServerSync } from "./controller/servers/matchServers.js";
import servers from "./routes/servers/serverRoutes.js";
//admin routes
import users from "./routes/users/userRoutes.js";

export const setupAdminRoutes = (app: Express, basePath: string) => {
	app.use(
		basePath + "/api/admin/server", // will pass bc system admin but this is just telling us we need this
		servers,
	);

	app.use(
		basePath + "/api/admin/users",
		requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
		users,
	);

	// run the sync only on startup
	setTimeout(() => {
		mainServerSync();
	}, 5 * 1000);
};
