Typedef
Typedef
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Typedef on 9/17/2024 in #questions
_error.tsx on nextjs pages
Do you guys know if its possible to make a custom page for Vercel serverless timeouts, I tried _error and 500 on pages folder doesnt seem to work. Existing discussion on Vercel's github doesnt have replies either.
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 3/5/2024 in #questions
AccessDenied NextAuth
No description
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 2/14/2024 in #questions
NextAuth vercel preview getserversession returns null
I'm using next pages, My getserversession on trpc createContext is returning null on preview deployments, anyone know why this is? useSession gets the right session tho
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 11/21/2023 in #questions
Vercel Out of memory event error
No description
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 10/5/2023 in #questions
NextJS app in a wordpress subdirectory
How would i deploy a Nextjs App on a wordpress subdirectory? any ideas?
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 9/20/2023 in #questions
Selecting through transparent background KonvaJS
No description
4 replies
TTCTheo's Typesafe Cult
Created by Typedef on 9/14/2023 in #questions
WordPress Landing + NextJS Dashboard
What’s the best way to combine a wordpress landing page to a nextjs dashboard with the same domain? Wordpress -> domain.com NextJS Dashboard -> app.domain.com
6 replies
TTCTheo's Typesafe Cult
Created by Typedef on 9/5/2023 in #questions
TRPC's useContext does not invalidate query.
No description
4 replies
TTCTheo's Typesafe Cult
Created by Typedef on 9/1/2023 in #questions
TRPC The inferred type of this node exceeds the maximum length the compiler will serialize.
No description
3 replies
TTCTheo's Typesafe Cult
Created by Typedef on 8/1/2023 in #questions
Redux reducer type error
3 replies
TTCTheo's Typesafe Cult
Created by Typedef on 7/26/2023 in #questions
NextAuth manual email verification
Im trying to implement manual email verification. So I created a VerificationToken with the identifier and token but when going to the link I'm always getting an error.
http://localhost:3000/api/auth/callback/email?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fapp%2Fdashboard&token=rbaykgmrwek9nhpocro27emr1uobwq5axonlq4ykarg080jj9byjxub5bt7ztj2i&email=[EMAIL]
http://localhost:3000/api/auth/callback/email?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Fapp%2Fdashboard&token=rbaykgmrwek9nhpocro27emr1uobwq5axonlq4ykarg080jj9byjxub5bt7ztj2i&email=[EMAIL]
Am I not doing it correctly? Dont I just need to create a verification token in the database and replace the query params?
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 7/26/2023 in #questions
NextAuth getting session token in the backend.
Is there a way to get the session token in the backend? whats the best way to do this? Edit: got it from req
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 7/12/2023 in #questions
Generating 1200x1200 10,000 unique images in lambda.
I'm using lambda for this one, I'm generating 1200x1200 10,000 unique images but it reaches the timeout limit. Any recommendation to make this faster? without removing status updates.
// generate images from layers
const canvas = createCanvas(dimension.width, dimension.height);
const ctx = canvas.getContext("2d");

for (let i = 0; i < metadata.length; i++) {
console.info(`<${userId}>`, `generated image #${i}`);
ctx.clearRect(0, 0, dimension.width, dimension.height);

const data = metadata[i];
const traitImages = data.attributes.map((attr) =>
layerMap.get(attr.trait_type + attr.value),
);

for (const image of traitImages) {
ctx.drawImage(image, 0, 0, dimension.width, dimension.height);
}

archive.append(canvas.toBuffer("image/png"), { name: `images/${i}.${format}` });

// if divisible by 5 update status
if (i % 5 === 0) {
await collection.updateOne({ userId }, { $set: { status: i.toString() } });
}
}
console.info(`<${userId}>`, "generated images");
await collection.updateOne({ userId }, { $set: { status: "processed" } });
// generate images from layers
const canvas = createCanvas(dimension.width, dimension.height);
const ctx = canvas.getContext("2d");

for (let i = 0; i < metadata.length; i++) {
console.info(`<${userId}>`, `generated image #${i}`);
ctx.clearRect(0, 0, dimension.width, dimension.height);

const data = metadata[i];
const traitImages = data.attributes.map((attr) =>
layerMap.get(attr.trait_type + attr.value),
);

for (const image of traitImages) {
ctx.drawImage(image, 0, 0, dimension.width, dimension.height);
}

archive.append(canvas.toBuffer("image/png"), { name: `images/${i}.${format}` });

// if divisible by 5 update status
if (i % 5 === 0) {
await collection.updateOne({ userId }, { $set: { status: i.toString() } });
}
}
console.info(`<${userId}>`, "generated images");
await collection.updateOne({ userId }, { $set: { status: "processed" } });
9 replies
TTCTheo's Typesafe Cult
Created by Typedef on 7/11/2023 in #questions
NextAuth dangerous website on email login
I keep getting dangerous website on chrome when I click on the url in the login email from email provider. I believe its caused by secure: false from my nodemailer options. I am using outlook's smtp with port 587 and need to turn off secure false and enable tls instead. Any workarounds?
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 6/30/2023 in #questions
Need advice on handling 10,000 images on Lambda
I need advice, I have a SQS that triggers lambda, it's an image processor that takes in 10,000 images and archives them in a zip file then uploads it to S3. I'm getting array buffer allocation on the archiving part. I might need more memory, currently has a max of 2560mb ram. This might be happening because I'm putting all the archived objects in a buffer instead of streaming, but it doesnt not work if i stream on lambda.
archive.finalize();
const buffer = [];
archive.on("data", (data => buffer.push(data)));

archive.on('end', (async () => {
const data = Buffer.concat(buffer);

await putObjectToS3(`generator/${userId}/collection.zip`, data);
console.info(`<${userId}>`, "sent zip file to s3");

await collection.updateOne({ userId }, { $set: { status: "completed" } });

resolve(formatResponse({
statusCode: 200,
body: { code: "SUCCESS" },
}))
}))
archive.finalize();
const buffer = [];
archive.on("data", (data => buffer.push(data)));

archive.on('end', (async () => {
const data = Buffer.concat(buffer);

await putObjectToS3(`generator/${userId}/collection.zip`, data);
console.info(`<${userId}>`, "sent zip file to s3");

await collection.updateOne({ userId }, { $set: { status: "completed" } });

resolve(formatResponse({
statusCode: 200,
body: { code: "SUCCESS" },
}))
}))
Should I make two lambda functions one for processing the image and uploading everything to s3, and another one for zipping it?
6 replies
TTCTheo's Typesafe Cult
Created by Typedef on 6/28/2023 in #questions
Archiving on serverless functions
Does anyone know any zipper/achiver library that works on serverless functions?
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 3/24/2023 in #questions
How to send ReadableStream through trpc
I’m using OpenAIs API and they have the option to send ReadableStream to send chunks of data by enabling the stream option. We all know that TRPC can only pass json from backend to frontend. Just wondering if it’s possible to pass a ReadableStream? Is it serializable?
9 replies
TTCTheo's Typesafe Cult
Created by Typedef on 2/22/2023 in #questions
[Help] Turbo shared types
I have a turborepo with two apps (web and embed). web is a t3 stack and embed is a create-react-app. I am trying to use the trpc endpoint from web to embed. I managed to make it work by configuring web's cors. However, I am getting type issues when importing AppRouter in the embed app. I don't think you can just import AppRouter from web like import type { AppRouter } from "../../../web/src/server/routers/_app"; which is currently what I am doing. So my question is how would I go about this? do I need to somehow share the types between the two? if so how would I do it?. Should I just seperate trpc as an internal package?
3 replies
TTCTheo's Typesafe Cult
Created by Typedef on 1/5/2023 in #questions
Next Auth Production Issue
I have a web app using session auth of NextAuth for authentication. It works fine locally, however, when deployed to Vercel, it errors out when logging in via Email Provider or Credentials. I am getting this weird error: In the console:
SyntaxError: Unexpected token 'A', "An error o"... is not valid JSON
SyntaxError: Unexpected token 'A', "An error o"... is not valid JSON
In network tab: StatusCode: 504 Request: Post RequestURL: https://<myappname>.vercel.app/api/auth/signin/email? Payload:
email: <myemail>@outlook.com
csrfToken: 40e860911c6388162f02e7df9ba7ad9d42b63344769c16ab9e1f2a6025d968cc
callbackUrl: https://<myappname>.vercel.app/auth
json: true
email: <myemail>@outlook.com
csrfToken: 40e860911c6388162f02e7df9ba7ad9d42b63344769c16ab9e1f2a6025d968cc
callbackUrl: https://<myappname>.vercel.app/auth
json: true
Response: An error occurred with your deployment FUNCTION_INVOCATION_TIMEOUT
2 replies
TTCTheo's Typesafe Cult
Created by Typedef on 12/21/2022 in #questions
Redux Toolkit
Im new to redux, is it okay to store refs in redux store... should I disable the serializable check for it? or nah. What do you guys think?
41 replies