IT
TTCTheo's Typesafe Cult
•Created by IT on 10/27/2023 in #questions
Where Should I Place API Communication Files for OpenAI in a Next.js and tRPC T3 Stack?
And I was looking at a public repository a little. Why do you think the person of the repository below separates the API route and the tRPC for API communication?
API route: https://github.com/NathanLazo/chat-gpt-T3-stack/blob/main/src/pages/api/openai/gpt.ts
tRPC: https://github.com/NathanLazo/chat-gpt-T3-stack/blob/main/src/server/api/routers/gpt.ts
6 replies
TTCTheo's Typesafe Cult
•Created by IT on 10/27/2023 in #questions
Where Should I Place API Communication Files for OpenAI in a Next.js and tRPC T3 Stack?
@peterkyle01 Thanks for answering! I will try your advice.
Since using the T3 Stack also involves maintaining type safety, it's better to write the code for API communication on tRPC's server rather than placing it in Next.js's API routes, correct?
6 replies