Call route within route in server

How can I call a route in a different route. For example I have this route:

export const realEstateRouter = router({
    create: protectedProcedure
        .input(createRealEstateSchema)
        .mutation(async ({ ctx, input }) => {
          ...


I want to call that create function in a different route like this:

import { createUserActivitySchema } from "@/validation/user-activity";
import { protectedProcedure, router } from './../trpc';

export const userActivityRouter = router({
    create: protectedProcedure
        .input(createUserActivitySchema)
        .query(async ({ ctx, input }) => {

            const userId = ctx.auth.userId;

            if (!userId) throw new Error('User is not authenticated');

            const result = await ctx.prisma.userActivity.create({
                data: {
                    ...input,
                    user: {
                        connect: {
                            userId: userId
                        }
                    }
                }
            })

            return result;
        }),
});


But that does not work, any ideas?
Was this page helpful?