Balduin
Balduin
TTCTheo's Typesafe Cult
Created by Balduin on 8/27/2024 in #questions
NextJS REST API storing authed User per request
Hello i am looking for a good way to store the current User per request on the backend with NextJS endpoints. I saw in terminals github the usage of node:asyncs_hooks wrapped by an Actor. I like that concept, but i think i dont need to have an AsyncLocalStorage.
Are the best practices to do that? could i just use a Map / an Object instead of the AsyncLocalStorage?
4 replies
TTCTheo's Typesafe Cult
Created by Balduin on 12/27/2023 in #questions
Build step for monorepo package
Hello, i got a question regarding private packages in monorepos. When should private packages have a build step VS using ts path alias eg @ui/**: ../../packages/ui/**? i am currently having a build step, and i am thinking of removing it. then i would have to some changes to our tailwind config, so that the tailwind classes are getting bundled correctly. are their any trade offs or other experiences? our current setup: - 4 apps (api, website, customer ,admin) - 2 packages (ui, lib) - lib containing shared TS and config stuff for bussiness logik so it can be used for all websites - ui classic shared UI components (useing tailwind, want to also add shadcn/ui stuff)
2 replies
TTCTheo's Typesafe Cult
Created by Balduin on 11/21/2023 in #questions
Issues sending email with AWS SES
No description
2 replies
TTCTheo's Typesafe Cult
Created by Balduin on 11/21/2023 in #questions
Fire and forget endpoint
I am hitting an endpiont in my API ~ 1000 Times I like a second. In localhost I am getting an ECONNRESET error after like 150 request then after a while again 150 request pass. I am using axios to make theses calls. So on localhost I could imagine that a nextjs server can’t handle that many request. Production is using serviertes function so there shouldn’t be any issues there. I am worried for the invoking part. Is there any solution where I can just invoke a post request to an endpoint without creating a promise ( I guess that the axios client is trying to hold onto these even though I am not awaiting it) I tried to abort the request right after calling it. But then it throws and since I don’t await it an unhandled Exeption Appreciate some input 😄
2 replies
TTCTheo's Typesafe Cult
Created by Balduin on 11/6/2023 in #questions
API Design: PDF generation in a REST-API
We have a REST-API (NextJS) that uses react-pdf for PDF generation and s3 as a storage for these. One Route is handeling the Payment, it has these main task: - Create a XML, for the Bank that we upload manually - Updating the dB (marking stuff as booked, year, month and Invoice name) - Create a CSV, for tax stuff - Create & Upload Invoices (PDFs) the XML and CSV File is getting downloaded as a ZIP and also uploaded to s3 as a backup. The db is getting updated no matter what happens with the PDF generation and upload, like optimistic updates. So the PDFs are not used we are just awaiting the creation and upload, the process logs errors itself, this is also the case for other Routes where PDFs are getting created and uploaded, but on error we only Log, no feedback to the enduser. The PDF generation and upload takes a long time (2-4s). The Payment route is taking very long, exceeding the 5min timeout for serverless and other routes are uneccessary long because of PDF generation. THE QUESTION Is it a good Idea to make a new endpoint that is handeling the PDF generation? I am thinking of something like that: - authentication with a secret in the env (like a cronjob) - For the different types of PDFs we have a unique Query: eq: pdf_gen?type=invoice - we would also have zod validators for each PDF - the File name would be passed in the req body, the key for the file would be created from the recieved data - in the payment route (or other routes this PDF gen) we simply just invoke this enpoint with the secret, the type query param. and the needed data for one PDF Since we are using serverless functions with vercel, we should be able to handle the invocation of the same route ~1000 times in like a second. also s3 can handle this amount of request. 1. is it bad practice to invoice itself in an REST-API? 2. is it bad to pass the Filename as part of the request, but the Key is generated from the given data for the PDF? eg.: is that bad design
3 replies
TTCTheo's Typesafe Cult
Created by Balduin on 10/30/2023 in #questions
Framework for smaller projects
Hey ppl, i am looking for a lightweight alternative for NextJS for creating landing pages, smaller project, no backend, maybe just a contact Form, that kind of style. Having my eyes in Vite, Astro and Svelte. Any recommendations?
7 replies
TTCTheo's Typesafe Cult
Created by Balduin on 10/30/2023 in #questions
Prisma Where Statement with locked presets
No description
2 replies
TTCTheo's Typesafe Cult
Created by Balduin on 8/24/2023 in #questions
NextJS app pretty slow
No description
44 replies
TTCTheo's Typesafe Cult
Created by Balduin on 6/10/2023 in #questions
turbo lint env not typed
4 replies
TTCTheo's Typesafe Cult
Created by Balduin on 5/8/2023 in #questions
Turborepo compiling issues
12 replies
TTCTheo's Typesafe Cult
Created by Balduin on 3/6/2023 in #questions
NextAuth with a Rest API
So I have 3 Servers: - API (should handle login with nextauth) - Admin - Customer Currently we aren’t using nextauth, just email, password logins. We want customers to login just with their email (Email-Provider) and the Admins with Credentials ( force yubikey ). Now I am having problems setting up nextauth. My first two solutions where: 1. Open API/api/auth/Admin/Signum OR API/api/auth/Customer/signin -> go back to adminpage if auccess 2. POST Logins manually to the api routes PROBLEMS: 1. The redirect to the original page doesn’t work. 2. CORS is blocking is A new solution was to wrap the admin _app in a SeasionProvider and use the signIn function from NextAuth in the frontend. My thought was with setting the NEXTAUTH_URL to the api url I could send the sign data to the API url and additionally could use “useSession” in the frontend. Sadly this isn’t working. Any Ideas to solve this issue?
2 replies
TTCTheo's Typesafe Cult
Created by Balduin on 2/6/2023 in #questions
Posting PDF to S3
Hello, I Hope this is the right section for Question, it feels like it is. I am working on an Project, part of it is an REST Api and different front ends (admin page, employee page, customer page ). We are using aws s3 to save relevant files, like customer bills, employees qualifications, etc. Primarily PDF (if not only). I am struggling to POST PDF documents to S3. Currently it goes from client -> rest api -> s3. The PDF Saved on S3 is blank. I Tried debugging client -> api-> client. Here is the PDF also blank. So I guess I am not sending the PDF correctly, googling gives me many different solutions, none work. I am working in the nextjs framework. Anybody already had issues with that?
6 replies