trpc openapi api memory problem

Hi Everyone, I am facing memory issues with trpc-openapi. I have a full-stack app in NextJS using TRPC. When I visit the /openapi route to visit the swagger documentation the server memory limit is reached and the server crashes. Please see attached images. Can someone please help me out with this? Thanks!
R
Rammstein210d ago
Provide environment Information System: Cloud service provider: Render OS: 22.04.1-Ubuntu CPU: AMD EPYC 7R13 Processor Memory: 2.00 GB Binaries: Node: 18.12.1 Packages: @trpc/client: 10.5.0, @trpc/next:10.5.0, @trpc/react-query: 10.5.0, @trpc/server:10.5.0, next: 12.1.6, react: "18.1.0", swagger-ui-react:^4.15.5, trpc-openapi:^1.0.0, Code:
server/routers/_app.ts
import {router} from '../init';
import {userRouter} from "./user";
import {cloudmateRouter} from "./cloudmate";
import {workspaceRouter} from "./workspace";
import {channelRouter} from "./channel";
import {projectRouter} from "./project";
import {SMSRouter} from "./sms";
import {customFieldRouter} from "./customField";
import {EmailRouter} from "./email";
import {testRouter} from "./test";
import {microsoftRouter} from "./microsoft";
import {googleRouter} from "./google";
import {AsanaWebhookRouter} from "./asanaWebhook";
import {draftRouter} from "./draft";
import {taskRouter} from "./task";
import {organizationRouter} from "./organization";
import {commandRouter} from "./command";
import {eventFilterRouter} from "./eventFilter";
import {workerRouter} from "./worker";
import {exceptionRouter} from "./exception";

export const appRouter = router({
asanaWebhook:AsanaWebhookRouter,
channel: channelRouter,
cloudmate: cloudmateRouter,
command:commandRouter,
customField: customFieldRouter,
draft: draftRouter,
email: EmailRouter,
eventFilter:eventFilterRouter,
exception:exceptionRouter,
google: googleRouter,
microsoft: microsoftRouter,
organization:organizationRouter,
project: projectRouter,
sms: SMSRouter,
task: taskRouter,
test: testRouter,
user: userRouter,
worker:workerRouter,
workspace: workspaceRouter,
});

export type AppRouter = typeof appRouter;
server/routers/_app.ts
import {router} from '../init';
import {userRouter} from "./user";
import {cloudmateRouter} from "./cloudmate";
import {workspaceRouter} from "./workspace";
import {channelRouter} from "./channel";
import {projectRouter} from "./project";
import {SMSRouter} from "./sms";
import {customFieldRouter} from "./customField";
import {EmailRouter} from "./email";
import {testRouter} from "./test";
import {microsoftRouter} from "./microsoft";
import {googleRouter} from "./google";
import {AsanaWebhookRouter} from "./asanaWebhook";
import {draftRouter} from "./draft";
import {taskRouter} from "./task";
import {organizationRouter} from "./organization";
import {commandRouter} from "./command";
import {eventFilterRouter} from "./eventFilter";
import {workerRouter} from "./worker";
import {exceptionRouter} from "./exception";

export const appRouter = router({
asanaWebhook:AsanaWebhookRouter,
channel: channelRouter,
cloudmate: cloudmateRouter,
command:commandRouter,
customField: customFieldRouter,
draft: draftRouter,
email: EmailRouter,
eventFilter:eventFilterRouter,
exception:exceptionRouter,
google: googleRouter,
microsoft: microsoftRouter,
organization:organizationRouter,
project: projectRouter,
sms: SMSRouter,
task: taskRouter,
test: testRouter,
user: userRouter,
worker:workerRouter,
workspace: workspaceRouter,
});

export type AppRouter = typeof appRouter;
/pages/openapi.tsx
import type { NextPage } from 'next';
import dynamic from 'next/dynamic';
import 'swagger-ui-react/swagger-ui.css';

const SwaggerUI = dynamic(() => {
return import("swagger-ui-react");
}, { ssr: false });

const OpenAPIPage: NextPage = () => {
// Serve Swagger UI with our OpenAPI schema
return <SwaggerUI url="/api/openapi.json" />;
};

export default OpenAPIPage;
import type { NextPage } from 'next';
import dynamic from 'next/dynamic';
import 'swagger-ui-react/swagger-ui.css';

const SwaggerUI = dynamic(() => {
return import("swagger-ui-react");
}, { ssr: false });

const OpenAPIPage: NextPage = () => {
// Serve Swagger UI with our OpenAPI schema
return <SwaggerUI url="/api/openapi.json" />;
};

export default OpenAPIPage;
js /pages/api
import { NextApiRequest, NextApiResponse } from 'next';

import { openApiDocument } from '../../server/configs/openapi.config';

// Respond with our OpenAPI schema
const handler = (req: NextApiRequest, res: NextApiResponse) => {
res.status(200).send(openApiDocument);
};

export default handler;
import { NextApiRequest, NextApiResponse } from 'next';

import { openApiDocument } from '../../server/configs/openapi.config';

// Respond with our OpenAPI schema
const handler = (req: NextApiRequest, res: NextApiResponse) => {
res.status(200).send(openApiDocument);
};

export default handler;
pages/api/openapi/[...trpc].ts
import { NextApiRequest, NextApiResponse } from 'next';
import { createOpenApiNextHandler } from 'trpc-openapi';

import { appRouter} from '../../../server/routers/_app';
import {createContext} from '../../../server/context';


const handler = async (req: NextApiRequest, res: NextApiResponse) => {


// Handle incoming OpenAPI requests
return createOpenApiNextHandler({
router: appRouter,
createContext,
})(req, res);
};

export default handler;
import { NextApiRequest, NextApiResponse } from 'next';
import { createOpenApiNextHandler } from 'trpc-openapi';

import { appRouter} from '../../../server/routers/_app';
import {createContext} from '../../../server/context';


const handler = async (req: NextApiRequest, res: NextApiResponse) => {


// Handle incoming OpenAPI requests
return createOpenApiNextHandler({
router: appRouter,
createContext,
})(req, res);
};

export default handler;
js
R
Rammstein210d ago
No description
No description
R
Rammstein209d ago
Is there a way I can paginate/lazy load the /api/openapi.json?
More Posts
Context being destroyed in mutatorIm currently building an app using the t3 stack + clerk for auth I have an operation which relies oOptimizing Data Refresh with trpc in React/Nextjs? Is there a more efficient way?I'm working on a Nextjs project using trpc, and I've noticed that I'm repeating the same code for dacorsHi! Some problems with cors maybe you can help, ```readingbee.se/:1 Access to fetch at 'https://servShowing pending inside the request?I am using trpc with nextjs but when I am using hooks they're just not returning anything? Like it mOutput properties missing on frontend results (Type Infer)My trpc client is inferring the type without some properties from the object (See images for explenAvoid checking for TRPCClientError, and return the error in client query/mutateWhat i'm trying to do, is avoid doing try/catch on every trpc call to backend, if ZOD validation faiProperty 'query' does not exist on type ...I think this is an issue on my end here is how I am defining everything ``` export const t = initTRPuseQueries passing ctx data to splitLink not workingWhen tRPC is implemented with splitLink using useQueries does not pass cxt parameters to splitLink. Build and Publish on lambda from Github ActionsTrying to send my TRPC API on Lambda AWS + API Gateway. I have follow the documentation. But now honext-pwa with trpc and push notificationHow can I build an app with next-pwa, trpc and push notification?Forced router input?I have a user route which has routes like get, delete, create etc. Some of the routes I require extrAuthentication with Expo applicationHi guys, I wan't to convert my current application stack to T3 stack. Current stack is: - NestJS