Sean Cassiere
Sean Cassiere
Explore posts from servers
TTCTheo's Typesafe Cult
Created by cdodev on 5/10/2023 in #questions
I need a bit of help understanding trpc
The useQuery hook shouldn't be called inside of a useEffect. If you want to called the subsequent requests on the client, you could moove that logic into a child component.
export const Comp = () => {
const { data: posts } = api.posts.getAll.useQuery()
return <div>
{(posts ?? []).map(post => <SubComp key={post.id} postId={post.id} />)}
</div>
}

const SubComp = ({ postId }: { postId: string }) => {
const { data: post } = api.posts.getById.useQuery({ id: postId })

return <div>id: {post?.id}</div>
}
export const Comp = () => {
const { data: posts } = api.posts.getAll.useQuery()
return <div>
{(posts ?? []).map(post => <SubComp key={post.id} postId={post.id} />)}
</div>
}

const SubComp = ({ postId }: { postId: string }) => {
const { data: post } = api.posts.getById.useQuery({ id: postId })

return <div>id: {post?.id}</div>
}
8 replies
TTCTheo's Typesafe Cult
Created by kevinka on 5/6/2023 in #questions
should I share TRPC client in a internal package?
It's best to export the formed appRouter (plus its typings) and the createContext function. Then, in the server, import the appRouter and the createContext fn, and create the trpc instance on the server. And on the client apps, import the typings for AppRouter and create the trpc-react-query client-api to call the endpoint on the server. The create-t3-turbo repo, is a great reference for this: https://github.com/t3-oss/create-t3-turbo/
3 replies
TTCTheo's Typesafe Cult
Created by Forsto on 1/23/2023 in #questions
Issue with server.msj
This prefix should only be used when it is safe to be exposed to the client-side, and anything specifically for the server should NOT be exposed to the client.
6 replies
TTCTheo's Typesafe Cult
Created by Forsto on 1/23/2023 in #questions
Issue with server.msj
It should be like
AWS_ACCESS_KEY_ID=key
AWS_SECRET_ACCESS_KEY=key
AWS_ACCESS_KEY_ID=key
AWS_SECRET_ACCESS_KEY=key
6 replies
TTCTheo's Typesafe Cult
Created by Forsto on 1/23/2023 in #questions
Issue with server.msj
Remove the NEXT_PUBLIC_ prefix
6 replies
TTCTheo's Typesafe Cult
Created by cyremur on 1/19/2023 in #questions
Can I zod this gamestate?
const GameSchema = z.object({
id: z.string(),
status: z.enum("initializing","waitingOpponent","started","finished"),
field: // your zod schema for this,
entities: z.array(/** you zod schema for this */),
initiative: z.array(z.number()),
round: z.number(),
turn: z.number(),
hands: z.array(z.array(/** you zod schema for this */)),
decks: z.array(/** you zod schema for this */)
});

export type TGameSchema = z.infer<typeof GameSchema>
const GameSchema = z.object({
id: z.string(),
status: z.enum("initializing","waitingOpponent","started","finished"),
field: // your zod schema for this,
entities: z.array(/** you zod schema for this */),
initiative: z.array(z.number()),
round: z.number(),
turn: z.number(),
hands: z.array(z.array(/** you zod schema for this */)),
decks: z.array(/** you zod schema for this */)
});

export type TGameSchema = z.infer<typeof GameSchema>
6 replies
TTCTheo's Typesafe Cult
Created by Xaohs on 1/5/2023 in #questions
How to check if type is array?
Cannot say for certain TBH. What I do know is that in my version of it, I'm directly passing the value into the Array.isArray vs accessing the reference of it on the object outside of the context of the .forEach.
13 replies
TTCTheo's Typesafe Cult
Created by Xaohs on 1/5/2023 in #questions
How to check if type is array?
This would also work.
[...Object.entries(filterOptions)].forEach(([key, value]) => {
if (key === "price") {
// whatever custom logic you have here
return;
}

if (Array.isArray(value) && !value.includes("test")) {
// whatever logic goes here
}
});
[...Object.entries(filterOptions)].forEach(([key, value]) => {
if (key === "price") {
// whatever custom logic you have here
return;
}

if (Array.isArray(value) && !value.includes("test")) {
// whatever logic goes here
}
});
13 replies
TTCTheo's Typesafe Cult
Created by codefork on 10/4/2022 in #questions
Can anyone jump on call to help with dnd-kit will pay for tutor $100 for the hour
I'd probably just recommend hacking away at it till you get what you are looking for.
3 replies
TTCTheo's Typesafe Cult
Created by codefork on 10/4/2022 in #questions
Can anyone jump on call to help with dnd-kit will pay for tutor $100 for the hour
3 replies
TTCTheo's Typesafe Cult
Created by Web Dev Cody on 10/4/2022 in #questions
railway app websockets?
Yup yup, just need to find a day I'm free.
14 replies
TTCTheo's Typesafe Cult
Created by Halu on 10/4/2022 in #questions
Why is Prisma the exception to ORM hate?
17 replies
TTCTheo's Typesafe Cult
Created by Web Dev Cody on 10/4/2022 in #questions
railway app websockets?
Will do 🙌🏼
14 replies
TTCTheo's Typesafe Cult
Created by Web Dev Cody on 10/4/2022 in #questions
railway app websockets?
Yup quite possibly just moving the container resources up and down. TBH I haven't really been bothered to load test it. Maybe if I get a free day I may give it a shot... Just don't want to walk away with a ridonkulous bill 😬
14 replies