Sammy
Sammy
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Sammy on 2/6/2024 in #questions
Default JSON Value
Hello, I am using T3 stack with prisma and planetscale. I am trying to add a new column to my database table that is of type JSON and defaulting it to and empty JSON array like the following which is what I found
newCol Json @default("[]")
newCol Json @default("[]")
In prisma this works fine, but when I psuh it to planetscale it doesn't recognize the default. I only see:
newCol json NOT NULL
newCol json NOT NULL
and I get a deployment error on planetscale because it couldn't pick up on the @default. From my research newer versions of MySQL should support setting a default JSON value
3 replies
TTCTheo's Typesafe Cult
Created by Sammy on 12/8/2023 in #questions
Extract PDF Formatting
I'm building a web app (using t3 stack) that prompts the user for about ~100 page PDF and that PDF is made up of multiple sections (20-30) each will have it's own page. On each section page, I want to display the full text of that section with the proper formatting (text positioning, bold, underline, etc...). I can isolate each section by identifying the section title using a regex pattern (i.e. Section 1, Section 2, etc...). The problem I am running into is when I attempt to extract the text from the pdf I lose all the formatting. Is there a way to also extract the formatting of the text or if there's a way to render just a specific section of the pdf instead of rendering a specific page or the whole pdf. Note: I still want the text to highlightable by the user, so turning it into a canvas/image won't work.
2 replies
TTCTheo's Typesafe Cult
Created by Sammy on 11/29/2023 in #questions
Redirect user to 404 not found if data doesn't exist
I am using t3 stack with pages directory. Since I save the projectId in the URL and use that to access a specific project the user navigates to anyone can manually adjust the url to a non-existant projectID and they will be taken to an empty or continuously loading page (depends how its handled). I want to take them to a 404 instead. How can I do that? I tried the following but it 404s even for existing projects
const { data: projectData, isLoading: isLoadingProjectData } = api.project.getById.useQuery({ id: projectId }, { enabled: !!projectId });

if (!projectData && !isLoadingProjectData) {
notFound();
}
const { data: projectData, isLoading: isLoadingProjectData } = api.project.getById.useQuery({ id: projectId }, { enabled: !!projectId });

if (!projectData && !isLoadingProjectData) {
notFound();
}
3 replies
TTCTheo's Typesafe Cult
Created by Sammy on 11/22/2023 in #questions
<Context.Consumer.Provider> Warning
No description
1 replies
TTCTheo's Typesafe Cult
Created by Sammy on 5/13/2023 in #questions
Create and Download PDF
I have a web app that allows users to edit a table including drag/dropping rows, change row colors, edit text, etc... Once they are done editing it I want them to be able to export the table as PDF. However, I've tried some different PDF libraries and none of them have a straightforward way of taking your component including the Tailwind CSS styles and create a multi-page PDF. I also don't want to convert my component into an image using something like html2canvas to allow users to highlight text on the PDF. Here are the libraries I've tried: react-pdf jsPDF Any suggestions on a library or method I can use?
1 replies
TTCTheo's Typesafe Cult
Created by Sammy on 4/23/2023 in #questions
T3 stack + Python Script?
I'm developing a web app that basically takes a PDF, processes the text, calls ChatGPT API and outputs a table for the user to edit, drag/drop rows, etc.. I've set up the project using T3 stack & deploying on Vercel however my PDF processing script is in Python and it takes as input a PDF and returns JSON. I'm not sure what the best way to integrate this Python script whether to spin up a separate lambda for it or integrate it on the same lambda (and if so how do I integrate a Python script into a Nextjs project). I attempted a separate Lambda on Vercel but it hangs and ends up timing out. However, when I spun up EC2 on AWS Elastic beanstalk it worked fine but feels inefficient to be managing two different services (AWS ebs & Vercel). Eventually I don't want to have a separate Python script but for the meantime I have to work with what I got.
3 replies
TTCTheo's Typesafe Cult
Created by Sammy on 4/9/2023 in #questions
Having two subdomains
How can I accomplish having two subdomains in a Nextjs project that works well with Clerk? I want www. for public facing (homepage,about,etc...) and app. subdomain for logged in part of my site.
6 replies