import {
  getConsoleSettingHandler,
  putConsoleSettingHandler,
} from "@/controllers/admin/console-settings/console-settings.controller";
import { withConsoleUserSession } from "@/middlewares/withConsoleUserSession";
import { Hono } from "hono";

export const ConsoleSettingsRoutes = new Hono();

/*
 * Reads are gated on a console session only, with no feature privilege: the
 * promo theme has to render for every user, so requiring a specific feature
 * would leave operators without it looking at an unstyled console.
 *
 * Writes are gated on super admin inside the handler rather than by
 * `withConsoleUserRole`, because this is not a feature-scoped permission —
 * there is no "console-settings" feature to grant.
 */
ConsoleSettingsRoutes.get(
  "/:key",
  withConsoleUserSession(),
  getConsoleSettingHandler,
);

ConsoleSettingsRoutes.put(
  "/:key",
  withConsoleUserSession(),
  putConsoleSettingHandler,
);
