sumatoken
sumatoken
Explore posts from servers
TTCTheo's Typesafe Cult
Created by sumatoken on 10/3/2023 in #questions
Proper 3rd party APIs config in Next.js
Hey everyone, I tried to move a set of serverless functions to a standalone Fastify server for some reasons which are not relevant to this question. I faced an issue with request headers when I tried sending requests using fetch to my Fastify server. The headers coming from Next.js were totally different from the headers I'd expected. I tried comparing headers from my Next.js API route and from Fastify, and they were missing some fields like the Clerk auth token. I edited the next.config.js like so to solve this issue
async rewrites() {
return [
{
source: "/fastify/api/db/preview",
destination: "http://localhost:8000/api/db/preview",
},
];
},
async rewrites() {
return [
{
source: "/fastify/api/db/preview",
destination: "http://localhost:8000/api/db/preview",
},
];
},
And now I have access to all headers coming from Next.js. My question again guys is, do you think this is good practice? And how could I make it scale if I have a large set of Fastify API endpoints? Thank you.
2 replies
TtRPC
Created by sumatoken on 9/14/2023 in #❓-help
tRPC Express server with Next.js
No description
6 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 9/14/2023 in #questions
tRPC Express server with Next.js
No description
2 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 9/6/2023 in #questions
Importing npm packages in Deno
Hello everyone, I am trying to create a Supabase Edge Function which uses Deno runtime. I want to import the Clerk SDK from NPM but I am running into a Not found error. Here is my import statement:
import { clerkClient } from "npm:@clerk/clerk-node-sdk";
import { clerkClient } from "npm:@clerk/clerk-node-sdk";
I am new to Deno and I'd appreciate any help I could get.
2 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 9/1/2023 in #questions
Handling tRPC or React Query errors on the client side.
Hey everyone, I wanted to get prespective on how would you handle errors on the client side side when you're doing a query or mutation. Let's say, it's a login form and the user somehow bypassed the built in input validation in HTML and browsers. How do I handle the error that has been thrown by zod on the server side and do some effect on the client side. Do I catch the error inside
javascript onError(){}
javascript onError(){}
and update some state with the error returned and then make the user know that the input value was wrong. What are other approaches to this?
6 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 8/27/2023 in #questions
tRPC Context object empty
Hey guys, I wanted to try to implement context using tRPC. I followed the docs line by line but I keep getting an empty object when I return the ctx in my procedure. Here is my code: context.ts
export async function createContext(opts: CreateNextContextOptions) {

return {
token: "secret-hash",
};
}

export type Context = inferAsyncReturnType<typeof createContext>;
export async function createContext(opts: CreateNextContextOptions) {

return {
token: "secret-hash",
};
}

export type Context = inferAsyncReturnType<typeof createContext>;
` trpc.ts
const t = initTRPC.context<Context>().create();

const isAuthed = t.middleware(async ({ next, ctx }) => {
if (!ctx) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
return next({
ctx: {
session: ctx,
},
});
});
export const protectedProcedure = t.procedure.use(isAuthed);
const t = initTRPC.context<Context>().create();

const isAuthed = t.middleware(async ({ next, ctx }) => {
if (!ctx) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
return next({
ctx: {
session: ctx,
},
});
});
export const protectedProcedure = t.procedure.use(isAuthed);
router.ts
print: protectedProcedure
.input(
z.object({
name: z.string(),
})
)
.mutation(async (opts) => {
return opts.ctx; // {}
}),
print: protectedProcedure
.input(
z.object({
name: z.string(),
})
)
.mutation(async (opts) => {
return opts.ctx; // {}
}),
I'd appreciate any help I could get
3 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 8/15/2023 in #questions
What is the BEST ORM for Vercel Edge
I am trying to migrate to Vercel Edge. Currently using pg as my Postgress client, but it is not compatible with edge runtime. What do you guys suggest?
4 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 8/11/2023 in #questions
How to deploy a GitBook on Vercel?
Hey everyone, I've created a Gitbook but I am stuck on how to deploy it to Vercel. I use Vercel to deploy Node projects but it is my first time using MDX and Gitbook. I need help.
5 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 8/7/2023 in #questions
How to handle Prod and Dev in Vercel.
Hey everyone, I've been using Vercel to host web apps for a decent amount of time. But I still can't figure out a way to separate prod from dev on deployments. Let's say I have a github repo with a main and dev branches. I'd like the prod deployment to be rebuilt on every push to main. And I'd like the dev deployment to be built on every push to dev. How do you guys work out this prod dev thing when using Vercel?
6 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 8/3/2023 in #questions
Cool svg animation insight.
Hello dear front-end engineers, Can you give me some insight on how this cool effect is implemented in nextjs.org.
10 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 7/26/2023 in #questions
Monitoring APIs hosted on Vercel.
Hello everyone, Does any one know a free tool that helps monitor application hosted on Vercel. Bonus points if works well with APIs, because I have an API deployed on Vercel and I'd like to monitore it.
4 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 7/3/2023 in #questions
Animated Slider
Hello everyone , I am trying to make a form in which users can enter one input at a time and they're able to do so with a button click that slides to the next input just like a carousel. I am using React and TailwindCSS. What do you guys recommend? Is there an animation library for my use case? Or should I implement it myself?
2 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 2/19/2023 in #questions
Export a Planetscale database.
Hello everyone, this question is related to Planetscale. I have a Planetscale db with 2 tables. Students and certificates. Each student has one certificate. Is there any way to export the data in order to read it with Excel?
5 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 2/16/2023 in #questions
Type error on Vercel prod
5 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 2/16/2023 in #questions
Removing duplicate items in Planetscale
Hey everyone, I am stupid, I forget to implement a unique constraint on one of my db fields. Because of that some users registered multiple times with same value which is supposed to be unique. Now I can't lose 200 rows of data and I'm running out of time. I need to remove all duplicate items. I'm using nextjs with trpc and prisma. Any quick solutions?
5 replies
TTCTheo's Typesafe Cult
Created by sumatoken on 12/8/2022 in #questions
Hello everyone, I may need some of your front-end expertise on this one.
14 replies