Cobain
Explore posts from serversTTCTheo's Typesafe Cult
•Created by Cobain on 3/19/2024 in #questions
Deploy backend to cloudflare workers
Hi! So i was thinking in deploying the tRPC backend to cloudflare workers, but I don't know if it is an option to host backend and frontend separately in T3 as they are evidently deeply related. Is it possible? If is not, is it at least possible to host the whole t3 app on the cloudflare stack?
2 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 2/8/2024 in #questions
Capture output in middleware?
Hi! I am making a middleware in TRPC which sends a log to DynamoDB, the thing is I managed to capture input of course, but don't know if I can capture the output (or response) of the endpoint to include it in the dynamodb item. Is it possible?
1 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 1/25/2024 in #questions
How to monitor and analyze web app and api usage?
Hi! I was wondering how could I collect some key metrics (I'm deploying the next app on docker) like my web app visits and load time divided per page or trpc endpoints metrics.
4 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 1/5/2024 in #questions
How to access files on production (Vercel deployment)
Hi! I'm have some mdx files which are directly red with readdirSync, so i have configured it to detect if it is in dev or prod environment. The mdx files are in /public/docs/*.mdx So when accessing in local enviroment i use path.join("public", "docs"), and when im in prod i use: path.join(process.cwd(), "docs"), which in vercel logs it says that it is trying to access /var/tasks/docs. And it is not finding the folder, however, when I look at the output info of my vercel deployment, the docs folder is there at the root with all the .mdx files, how do i access them in production?
3 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 11/23/2023 in #questions
Log elapsedMs to axiom
Hi! I want to track my endpoints speed, they involve querying my postgresql db as well as my redis cache, how could I log the elapsedMs to axiom? I know it grabs all console.logged data, but the elapsedMs is already being calculated in the loggerlink, is there some way to include that in the logs axiom recieve?
2 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 11/19/2023 in #questions
JSON Parsing, TRPC Client error
I have a project with various trcp endpoints on nextjs 13.5 and they are working fine on development, but when deploying to vercel i get this strange error of a non-whitespace character on all the GET operations:
[next-auth][error][CREATE_USER_EVENT_ERROR]
https://next-auth.js.org/errors#create_user_event_error Unexpected non-whitespace character after JSON at position 4 {
message: 'Unexpected non-whitespace character after JSON at position 4',
stack: 'TRPCClientError: Unexpected non-whitespace character after JSON at position 4\n' +
' at TRPCClientError.from (/var/task/.next/server/chunks/5.js:39:117279)\n' +
' at /var/task/.next/server/chunks/5.js:39:122357\n' +
' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
name: 'TRPCClientError'
}
[97;46m << query [1;97;46m #1 entities.getAll [0m {
input: undefined,
result: TRPCClientError: Unexpected non-whitespace character after JSON at position 4
at TRPCClientError.from (/var/task/.next/server/chunks/5.js:39:117279)
at /var/task/.next/server/chunks/5.js:39:122357
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
meta: undefined,
shape: undefined,
data: undefined,
[cause]: SyntaxError: Unexpected non-whitespace character after JSON at position 4
at JSON.parse (<anonymous>)
at parse (/var/task/.next/server/chunks/5.js:43:4667)
at /var/task/.next/server/chunks/5.js:43:3830
at onChunk (/var/task/.next/server/chunks/5.js:43:3983)
at readStandardChunks (/var/task/.next/server/chunks/5.js:43:4254)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async readLines (/var/task/.next/server/chunks/5.js:43:4064)
at async parseJSONStream (/var/task/.next/server/chunks/5.js:43:3670)
},
elapsedMs: 145
}
The connection with the db is working fine, so I can't seem to find the problem.
6 replies
TTCTheo's Typesafe Cult
•Created by Cobain on 11/7/2023 in #questions
How to refetch useQuery with different input
Hi!
I have a query run with useQuery in a parent component, and in a child component which just contains a react-hook-form with some options for filtering. The tRPC endpoint has some optional inputs for filtering the query, the thing is I want to handle the submit of the filter form in the child component and re run the query but with new inputs added, how can I do that?
I tried using the utils from the api.context and using the refetch, but that didn't make my data refresh. Maybe is worth noting that my parent component useQuery is using this flags:
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
4 replies