import { fromNodeHeaders } from "better-auth/node";
import type { Request, Response } from "express";
import { Router } from "express";
import { auth } from "../../../../pkg/auth/auth.js";
import { requireAuth } from "../../../../pkg/middleware/authMiddleware.js";
import changePassword from "./changeUserPassword.js";
import createUser from "./createUser.js";
import deleteUser from "./deleteUser.js";
import users from "./getUserRoles.js";
import grantRoles from "./grantRole.js";
import revokeRoles from "./revokeRole.js";

const router = Router();

router.use(
	"/",
	requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
	grantRoles,
);

router.use(
	"/new",
	requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
	createUser,
);

router.use(
	"/",
	requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
	revokeRoles,
);

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

router.use(
	"/changePassword",
	requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
	changePassword,
);

router.use(
	"/delete",
	requireAuth("user", ["systemAdmin", "admin"]), // will pass bc system admin but this is just telling us we need this
	deleteUser,
);

export default router;
