import { createCallerFactory, createTRPCRouter } from "@/server/api/trpc";
import {
  articleRouter,
  categoryRouter,
  usersRouter,
  authorRouter,
  appRouter as globalRouter,
  commentRouter,
} from "./routers";

export const appRouter = createTRPCRouter({
  article: articleRouter,
  category: categoryRouter,
  comment: commentRouter,
  users: usersRouter,
  author: authorRouter,
  app: globalRouter,
});

// export type definition of API
export type AppRouter = typeof appRouter;

/**
 * Create a server-side caller for the tRPC API.
 * @example
 * const trpc = createCaller(createContext);
 * const res = await trpc.post.all();
 *       ^? Post[]
 */
export const createCaller = createCallerFactory(appRouter);
