import { createRoute } from "../../modules/api-utils/createRoute";
import { apiResponse } from "../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { authMiddleware } from "../middleware/authorization";
import { getAllPermissionNodes } from "../../types/PermissionNodes";

/* /v1/permissions/nodes */
export default createRoute(
  "get",
  ["/nodes"],

  async (c) => {
    const allNodes = getAllPermissionNodes();

    const response = apiResponse.successful(
      "All Permission Nodes Fetched Successfully!",
      allNodes,
    );
    return c.json(response, response.status as ContentfulStatusCode);
  },
  authMiddleware({ permissions: ["role.read"] }),
);
