tRPCttRPC
Powered by
NazCodelandN
tRPC•3y ago•
6 replies
NazCodeland

merging other routers to appRouter

Hey everyone, I am using the https://icflorescu.github.io/trpc-sveltekit package in my SvelteKit project. My question is not related to that package (at least I don't think it is) I figured I mention it since it might be related and I just don't know...

I am wondering if I have this code,
// router/router.ts
import type { Context } from '$server/trpc/context';
import { initTRPC } from '@trpc/server';

export const tRPC = initTRPC.context<Context>().create();

export const publicProcedure = tRPC.procedure;
export const appRouter = tRPC.router;

export type AppRouter = typeof appRouter;
// router/router.ts
import type { Context } from '$server/trpc/context';
import { initTRPC } from '@trpc/server';

export const tRPC = initTRPC.context<Context>().create();

export const publicProcedure = tRPC.procedure;
export const appRouter = tRPC.router;

export type AppRouter = typeof appRouter;


and say I also have
// routers/user.ts
import { appRouter, publicProcedure } from '$server/trpc/router';

export const userRouter = appRouter({
    list: publicProcedure.query(() => {
        return [];
    })
});
// routers/user.ts
import { appRouter, publicProcedure } from '$server/trpc/router';

export const userRouter = appRouter({
    list: publicProcedure.query(() => {
        return [];
    })
});


am I able to merge the
userRouter
userRouter
onto the
appRouter
appRouter
directly within the
/router/user.ts
/router/user.ts
file?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

AppRouter nested routers/procedures are any when imported in monorepo
EilinisEEilinis / ❓-help
11mo ago
AppRouter type any?
RainePRRaineP / ❓-help
4y ago
Separating routers into their own modules and merging them causes "any" type in client
sugar_waterSsugar_water / ❓-help
3y ago
AppRouter Type Declaration Method
ThreeCrownTThreeCrown / ❓-help
8mo ago