Endgame1013
Endgame1013
TTCTheo's Typesafe Cult
Created by Endgame1013 on 1/8/2024 in #questions
Long-running processing with SQL
Hi everyone, I've got a feature request for a client where they want to regenerate potentially tens of thousands of SQL records on-demand within a few seconds up to a minute or two at max. In simple terms, they have a found set of Jobs where some cost items can be calculated based on the work done, materials, mileage, etc. and those items need to be stored/overwritten in SQL. As a naive approach I tried various methods like Promise.all() to create a bunch of Promises to be executed in parallel, but I quickly ran into a bunch of errors in Prisma, mainly due to the db running out of connections in the pool/timing out when fetching connections, etc. I know WebDevCody has put out a few videos (like this one) where he uses SQS queues to generate thousands of PDFs in only a few seconds. I need something that functions exactly like this, but somehow work around the DB connection limitations. I've been hacking at this for a couple weeks and would really appreciate any guidance. Thanks in advance!
2 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 11/24/2023 in #questions
The “correct” way of GraphQL
I’ve heard Theo, among other popular tech voices praise the use of GraphQL, but only when used correctly. I realize there are different opinions on this topic, but I’m genuinely curious what is the “right” way of implementing GraphQL? Has Theo ever addressed this directly?
3 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 6/9/2023 in #questions
API Layer with App Dir
Hi all, With tRPC still in limbo with the new app directory, I’m tempted to go back to GraphQL as my API layer for new projects going forward. I love tRPC for the most part, but having a backend so tightly coupled to the inner workings of Next.js means that significant changes (like the app directory) now seems risky to me. I’ve played with tRPC in Next.js 13.4 using the “hacks” floating around online, but none seem to have that “magic” that tRPC had back in the pages directory. I’m curious what you all are currently using for new projects. Are you switching API layers? Are you moving to the app directory? Do we even need APIs anymore? I want to know your thoughts.
6 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 6/5/2023 in #questions
NextJS Server Actions vs Traditional API
Can someone explain the benefit of using RSC data fetching/server actions as opposed to a traditional API (GraphQL, tRPC, REST)?
It seems that traditional “API” functionality such as middleware, external consumers, etc. is not something that can be done with server actions. To me, this seems like a bit of a step backwards in the context of a web app.
Are server actions intended to serve a different role entirely? I’m primarily a backend dev, so the concept of not having a traditional backend/API layer is still new to me. Thanks in advance!
43 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 3/31/2023 in #questions
Session Auth using Redis and next-session
Hey everyone, This is more of a resource than a question, but I wanted to share an elegant approach to session auth within NextJS (in my opinion).
Personally, I've not had a great time using Next-Auth since most projects I'm involved with use credential-based auth. I find Next-Auth is a bit too opinionated for my liking and requires a certain database structure. That, and I'm not too fond of JWTs. After doing some research, I stumbled across next-session, which allows you to create a custom session store. The next-session docs are clear and concise and helped me create a custom session store with Redis (using ioredis). I just wanted to share this solution, since this is something I've been looking for for some time. I hope this is able to help at least a few of you. Cheers! next-session docs: https://github.com/hoangvvo/next-session redis-next-session repo: https://github.com/nick-cheatwood7/redis-next-session
1 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 3/31/2023 in #questions
Session Auth without Next-Auth
Hi all, I’m primarily a backend dev with experience using Express/Fastify with session-based authentication using cookies and libraries like express-session.
I’m diving pretty deep into NextJS and the T3 stack, but one question I just haven’t been able to “crack” is how to do session auth using this stack. The vast majority of projects I’m in use credential-based auth, which I don’t find plays very nicely with Next-Auth which I know most Next devs use. I’ve tried it a number of times, but I really believe Next-Auth is a bit too opinionated for credentials (or at the very least requires a LOT of setup/boilerplate). That being said, has anyone had any success using a different library for session auth in NextJS? I really like using Redis for this, as that allows a method for revoking tokens/user sessions. Thanks in advance!
5 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 2/21/2023 in #questions
CRON jobs in the T3 stack
Hey everyone, I’ve got a project at work that is going to require the use of some CRON jobs. My background is primarily in Node, so I’m still learning the quirks of NextJS.
How would you go about implementing CRON jobs in NextJS? Is that even possible?
That combined with some other possible requirements (event queues, websockets, etc.) is making me lean towards migrating this project from the current NextJS backend over to Node using Fastify. Just curious where the community stands on this. Thanks in advance, you all rock!
6 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 2/14/2023 in #questions
Paginated Queries and Downloads
Hi all, I’ve got an application with a reporting module where the user can choose from some report params and then view a table (built with Tanstack Table) with the first 50 records.. I’m needing to add an “Export all” button that should page through all the data and write it out to an excel file. I’ve gone through multiple implementations of this, but so far I’ve only been able to make this work by writing the paginated query twice– once to power the table and one to fetch the data for the download (using tRPC’s useContext() hook). One reason I went this direction is because when performing the download, I don’t want the fetched data to cause a re-render of the table. Obviously, this is not ideal and I’d prefer to reuse the same query (without the need to invoke useContext()). Has anyone solved a similar problem? I’d really like some advice on this.
10 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 1/15/2023 in #questions
Using a Custom Server
Has anyone attempted implementing a custom server for their T3/NextJS project? I have a project currently built on CRA/Express written in JS that I would love to port over to the T3 stack. However, we will still need support for things such as session based auth (using some middleware like express-session) and web sockets. Both of these requirements seem to lend themselves to using a custom server in a NextJS app. Ideally, we would be able to use Fasitfy, if so. Curious to hear any thoughts/suggestions.
33 replies
TTCTheo's Typesafe Cult
Created by Endgame1013 on 1/4/2023 in #questions
Deploying to AWS Amplify
Hi, my company is wanting to deploy an internal T3 app, but hosted on AWS Amplify. I've seen various tuts on deploying Next.js apps on Amplify, but it seems that tRPC is not playing well with it. Does anyone have experience deploying to AWS Amplify, or otherwise have any suggestions? To preface, I've been told we cannot deploy to Vercel.
8 replies