import { Hono } from "hono";
import type { AppConfig } from "../config.js";
import { MiddlewareManager } from "../middlewares/middleware.js";
import { getNotesRouter } from "./notes.js";
import { getStripeRouter } from "./stripe.js";
import { getTabloRouter } from "./tablo.js";
import { getTabloDataRouter } from "./tablo_data.js";
import { getUserRouter } from "./user.js";

export const getAuthenticatedRouter = (config: AppConfig) => {
  const authRouter = new Hono();

  const middlewareManager = MiddlewareManager.getInstance();

  // Apply authentication middleware to all routes in this router
  authRouter.use(middlewareManager.auth);

  authRouter.route("/users", getUserRouter());
  authRouter.route("/tablos", getTabloRouter(config));
  authRouter.route("/tablo-data", getTabloDataRouter());
  authRouter.route("/notes", getNotesRouter());
  // stripe routes
  authRouter.route("/stripe", getStripeRouter(config));

  return authRouter;
};
