Yoers
Yoers
TTCTheo's Typesafe Cult
Created by Yoers on 1/5/2024 in #questions
Correct way to access session data, using server & client components
How comes you're using Lucia curiously? Next auth has been pretty amazing for me, so I can only imagine Lucia must have some really cool features
15 replies
TTCTheo's Typesafe Cult
Created by Yoers on 1/5/2024 in #questions
Correct way to access session data, using server & client components
Yeah I do, just can predict it becoming a pain in my ass down the line, but it's definitely nicer! I guess I will update as my current application grows haha 🙂
15 replies
TTCTheo's Typesafe Cult
Created by ODeadPool on 1/4/2024 in #questions
How to test concurrency?
Note to start: concurrency != parallelism. It's parallelism where you need to worry about shared memory access causing issues. Running code concurrenly does not mean parallel code execution will occur. Javascript is single threaded with its concurrency model being based on the event loop (which provides great performance without the need for additional threads, mostly). You don't need race detectors as it's not possible for code to run in parallel, meaning no shared memory access, which potentially causes isues such as with Golang go-routines. Look into the event loop to understand how node works, and understand its *concurrency * (AKA out of order code execution) model.
6 replies
TTCTheo's Typesafe Cult
Created by Yoers on 1/5/2024 in #questions
Correct way to access session data, using server & client components
I'm not really sure if getServerSession would have any impact on useSession (which AFAIK uses client side checks), I didn't really think they were linked? I did used to get some annoying flashing when using useSession a while back - which is nice to have gone when I use the server component approach (due to useSession having some weird bugs where it would return some odd states during it's loading lifecycle) Will have to look into Lucia when I get a minute 🙂
15 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Unable to --inspect tRPC endpoints
For anyone reading this thread in the future, I'm still unable to get --inspect to work on node or bun, as a (better) alternative you can use VSCode built in debugging The node launch.json configuration looks like this (just default works)
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Node run NPM script",
"type": "node",
"request": "launch",
"runtimeArgs": [
"run-script",
"dev"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Node run NPM script",
"type": "node",
"request": "launch",
"runtimeArgs": [
"run-script",
"dev"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
}
]
}
I'm unable to use bun's "debug script" feature, and opened an issue https://github.com/oven-sh/bun/issues/7798
5 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Unable to --inspect tRPC endpoints
No one any ideas? Bit of a deal breaker not being able to debug my code 😦
5 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
You know what, rm-rf'ing node_modules and then bun install as you suggested seems to have done the job. Not sure why the default NPM install failed across 2 projects - but thanks!
16 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
What do you mean, each fresh project has their own fresh node_modules no, or you're worried the global cache is corrupt?
16 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Unable to --inspect tRPC endpoints
No description
5 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
and do things not initially run locally via sqlite, as is the case with Prisma?
16 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
So I did a fresh install via npm create t3-app@latest multiple times with different names, same error each time That would rule out either the monorepo, or node_modules issue right?
16 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
Command works fine on prisma for me - shame though I wanted to try drizzle!
16 replies
TTCTheo's Typesafe Cult
Created by Yoers on 12/21/2023 in #questions
Fresh install results in drizzle error on "npm run db:push"
Anyone seen this? Seems drizzle is missing an export perhaps
16 replies
TTCTheo's Typesafe Cult
Created by l on 4/13/2023 in #questions
S3 with TRPC
CORS is only clientside protection, any server can just spoof the host header, meaning any malicious actor could still abuse.
15 replies
TTCTheo's Typesafe Cult
Created by Paul on 3/27/2023 in #questions
API's to update database - One POST path to update whole object or multiple?
I typically base my mutations around features. I.E a mutation called handleVote needs to update the User table to increment the post owner, and also the UserPost to add a new association of a vote against a post. You can then also have optional parameters, for example -
updateSelectedWidget: protectedProcedure
.input(
z.object({
widgetId: z.string(),
selectedDatabase: z.string().nullable().optional(),
selectedField: z.string().nullable().optional(),
})
)
.mutation(async ({ ctx, input }) => {
// If the user hasn't passed any widget ID, then look up first widget from database
const widgetId = input.widgetId;

// return first Widget associated to user
const res = await ctx.prisma.widget.findFirst({
where: {
id: widgetId,
},
});
if (!res) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to find existing widget",
});
} else {
// Update any fields that have been passed
const data = await ctx.prisma.widget.update({
where: {
id: widgetId,
},
data: {
selectedDatabase:
input.selectedDatabase === undefined
? res.selectedDatabase
: input.selectedDatabase,
selectedField:
input.selectedField === undefined
? res.selectedField
: input.selectedField,
},
});
if (!data) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to update widget",
});
}
}

return null;
}),
updateSelectedWidget: protectedProcedure
.input(
z.object({
widgetId: z.string(),
selectedDatabase: z.string().nullable().optional(),
selectedField: z.string().nullable().optional(),
})
)
.mutation(async ({ ctx, input }) => {
// If the user hasn't passed any widget ID, then look up first widget from database
const widgetId = input.widgetId;

// return first Widget associated to user
const res = await ctx.prisma.widget.findFirst({
where: {
id: widgetId,
},
});
if (!res) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to find existing widget",
});
} else {
// Update any fields that have been passed
const data = await ctx.prisma.widget.update({
where: {
id: widgetId,
},
data: {
selectedDatabase:
input.selectedDatabase === undefined
? res.selectedDatabase
: input.selectedDatabase,
selectedField:
input.selectedField === undefined
? res.selectedField
: input.selectedField,
},
});
if (!data) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to update widget",
});
}
}

return null;
}),
3 replies
TTCTheo's Typesafe Cult
Created by niels on 3/26/2023 in #questions
Buying domains and emails
Porkbun (you'll never use another registrar again after using these) + Fastmail with custom domain tier
21 replies
TTCTheo's Typesafe Cult
Created by Yoers on 3/26/2023 in #questions
Invalidating a single part of a larger query
Ok thanks @cje , perhaps an optimization i'll leave out for now. You presumably don't recommend this because the chance your local source will be out of sync with the server?
11 replies