t
tRPC
t
tRPC
Adopting trpc gradually in existing project.
Original message was deleted
tRPC
Join
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,111
Members
View on Discord
A
Alex / KATT 🐱
•
1/12/23, 1:51 PM
I usually do auth etc as a trpc middleware so i get the correct context swapping
A
Alex / KATT 🐱
•
1/12/23, 1:52 PM
example
:
https://trpc.io/docs/procedures#reusable-base-procedures
Define Procedures | tRPC
Procedures in tRPC is a very flexible primitive to create backend functions
; they use a builder pattern which means you can create reusable base procedures for different parts of your backend application
.
A
Alex / KATT 🐱
•
1/12/23, 7:17 PM
You can do middlewares that do stuff with the result
, but unsure if that
's what you
're looking for
A
Alex / KATT 🐱
•
1/12/23, 8:10 PM
i usually just do something like
void doAsyncThing().catch(console.error)
void doAsyncThing().catch(console.error)
A
Alex / KATT 🐱
•
1/12/23, 8:10 PM
if i don
't want a side
-effect blocking
A
Alex / KATT 🐱
•
1/12/23, 8:10 PM
if you do serverless it won
't work tho
A
Alex / KATT 🐱
•
1/12/23, 8:11 PM
then you need a worker queue or something that you push to
A
Alex / KATT 🐱
•
1/13/23, 1:24 PM
in serverless the instance might be killed any time after you
.end()
.end()
the res so you either have to push it elsewhere or slow down the response
.end()
.end()
void
doAsyncThing
().
catch
(console.error)
void
doAsyncThing
().
catch
(console.error)