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

/* /v1/schedule/count */
export default createRoute(
  "get",
  ["/count"],
  async (c) => {
    const count = await schedules.count();

    const response = apiResponse.successful(
      "Schedule count fetched successfully!",
      { count },
    );

    return c.json(response, response.status as ContentfulStatusCode);
  },
  authMiddleware({ permissions: ["schedule.fetch.many"] }),
);
