import { OpenAPIHono } from "@hono/zod-openapi";
import login from "./routes/login.js";
import register from "./routes/register.js";
import session from "./routes/session.js";
import getAccess from "./routes/user/getUserRoles.js";
import setAccess from "./routes/userAdmin/setUserRoles.js";
import profile from "./routes/user/profileUpdate.js";
import { areRolesIn } from "./utils/roleCheck.js";
import createUser from "./routes/userAdmin/createUser.js";
import allUsers from "./routes/userAdmin/getUsers.js";
import updateUser from "./routes/userAdmin/updateUser.js";
import allUserRoles from "./routes/userAdmin/getAllUserRoles.js";
import { massAccountCreation } from "./utils/DefaultAccountCreation.js";

const app = new OpenAPIHono();

// run the role check
setTimeout(() => {
    areRolesIn();
}, 5000);

const routes = [
    login,
    register,
    session,
    profile,
    getAccess,
    setAccess,
    createUser,
    allUsers,
    allUserRoles,
    updateUser,
] as const;

// app.route("/server", modules);
const appRoutes = routes.forEach((route) => {
    app.route("/auth", route);
});

// setTimeout(() => {
//     massAccountCreation();
// }, 1000 * 60);

export default app;
