realmers
realmers
TTCTheo's Typesafe Cult
Created by realmers on 3/2/2024 in #questions
trpc-openapi with t3-stack
I am wondering if anyone has any experience adding trpc-openapi to the t3stack. i have followed the basic steps of the readme guide and when i add a trpc-openapi handler to my app i get "tRPC failed on <no-path>: Not found" when calling a trpc procedure. this is my new [trpc].ts file
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { env } from "../../../env.mjs";
import { appRouter } from "../../../server/api/root";
import { createTRPCContext } from "../../../server/api/trpc";

import { createOpenApiNextHandler } from 'trpc-openapi';

// export API handler
export default createOpenApiNextHandler({

router: appRouter,
createContext: createTRPCContext,
onError:
env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
);
}
: undefined,
});

// Disable body parser - we want raw body
export const config = {
api: {
bodyParser: false,
},
}
import { createNextApiHandler } from "@trpc/server/adapters/next";
import { env } from "../../../env.mjs";
import { appRouter } from "../../../server/api/root";
import { createTRPCContext } from "../../../server/api/trpc";

import { createOpenApiNextHandler } from 'trpc-openapi';

// export API handler
export default createOpenApiNextHandler({

router: appRouter,
createContext: createTRPCContext,
onError:
env.NODE_ENV === "development"
? ({ path, error }) => {
console.error(
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
);
}
: undefined,
});

// Disable body parser - we want raw body
export const config = {
api: {
bodyParser: false,
},
}
Another question i have is how do i test a endpoint when using the t3stack. in my routers folder i have a router called accountRouter which has a procedure called register. would my request to that procedure which i have added trpc-openapi to be something like "http://localhost:3000/api/accountRouter/register/{paramater}?{value}" ?
5 replies
TTCTheo's Typesafe Cult
Created by realmers on 1/14/2024 in #questions
Increase api file size limit on t3 stack
Im sending a image that exceeds 1mb file size limit of nextjs api route handler, and want to increase the limit. I have found posts that talk about it like this one https://github.com/trpc/trpc/discussions/2590, but can't figure out where to apply this when im using the t3 stack. here is my [trpc].ts where i see this post talking about : ' import { createNextApiHandler } from "@trpc/server/adapters/next"; import { env } from "../../../env.mjs"; import { appRouter } from "../../../server/api/root"; import { createTRPCContext } from "../../../server/api/trpc"; // export API handler export default createNextApiHandler({
router: appRouter, createContext: createTRPCContext, onError: env.NODE_ENV === "development" ? ({ path, error }) => { console.error( ❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message} ); } : undefined, }); '
6 replies