Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
1 reply
barry

File sending on form submit

So I'm trying to make a mutation, and that should generate a txt file and send back to the user. So far I have this
import { z } from "zod";
import fs from "fs";

import { router, publicProcedure } from "../trpc";

export const fileRouter = router({
  get: publicProcedure
    .input(z.object({ navn: z.string(), email: z.string().email() }))
    .mutation(({ input }) => {
      const file = fs.writeFileSync("name.txt", input.navn + " " + input.email);
      return {
        file,
      };
    }),
});
Was this page helpful?