barry
barry
Explore posts from servers
TTCTheo's Typesafe Cult
Created by barry on 8/2/2024 in #questions
DISCORD OAUTH Problem
OAUTH2, Discord Anyone ever run into this error? https://gist.github.com/barrybtw/8bb94fdcdbbee3d1a24e0e4c2c2f8fea I can run it locally just fine, but whenever I deploy it, I get this error in my logs...? Somehow???? https://reactiflux-com.fly.dev/api/auth/callback/discord Redirects to localhost 3000 wtf I've searched the whole codebase for any references to localhost:3000 but no luck, so fucking confused lol Where's this shit coming from
9 replies
TTCTheo's Typesafe Cult
Created by barry on 12/19/2023 in #questions
Tailwind Intellisense CVA
{
"tailwindCSS.classAttributes": [
"class",
"className",
"ngClass",
".*Variants.*"
],
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
{
"tailwindCSS.classAttributes": [
"class",
"className",
"ngClass",
".*Variants.*"
],
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
I tried this... not working lol, no intellisense, using Vite & running with bun
13 replies
TTCTheo's Typesafe Cult
Created by barry on 12/19/2023 in #questions
Turborepo kicks my ass
Using turborepo, and I've got a package called ui in which I have components Said components does this import { cn } from "../../lib/utils" But I'd like to do this import { cn } from "@ui/lib/utils" There's no immediate errors in the package as the aliases and what not are set fine
//package.json
"aliases": {
"components": "@ui/components",
"utils": "@ui/lib/utils"
}
//package.json
"aliases": {
"components": "@ui/components",
"utils": "@ui/lib/utils"
}
//tsconfig.json
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@ui/*": ["./*"],
"@ui/components/ui*": ["./components/ui*"]
}
}
//tsconfig.json
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@ui/*": ["./*"],
"@ui/components/ui*": ["./components/ui*"]
}
}
But in the app where I import the Button component I get this error Failed to resolve import "@ui/lib/utils" from "../../packages/ui/components/button.tsx". Does the file exist? FULL ERROR: https://gist.github.com/barrybtw/2feb7de19242fc3229c35abaf37258c1
1 replies
TTCTheo's Typesafe Cult
Created by barry on 12/1/2023 in #questions
Caddyfile, docker-compose
I've got this Caddyfile
develupah.com {
route /api* {
reverse_proxy localhost:6060
}
}
develupah.com {
route /api* {
reverse_proxy localhost:6060
}
}
And it seems to block my SSL cert in development Any way to tell it to just, not use this in development with environment variables? And tell it to do something else but only in devleopment? Like
api.localhost {
route /api* {
reverse_proxy localhost:6060
}
}
api.localhost {
route /api* {
reverse_proxy localhost:6060
}
}
1 replies
DTDrizzle Team
Created by barry on 11/30/2023 in #help
drizzle + postgres + express + ts, errors
https://gist.github.com/barrybtw/67c379371c3f52a61758c94474e8ebf8 In regards to the route auth_router.post("/signup", () => ...), I get this error
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:393:5)
at ServerResponse.setHeader (node:_http_outgoing:644:11)
at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:393:5)
at ServerResponse.setHeader (node:_http_outgoing:644:11)
at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
I don't seem to be breaking that so a bit confused? And if I use a username that's already taken (username has the unique constraint) I get this error PostgresError: duplicate key value violates unique constraint "user_username_unique", and I can't import the type PostgresError as it's not exported but it's part of the types in the node modules, yet I can't import it without runtime errors. What's the standard for handling sql errors like this? SyntaxError: The requested module 'postgres' does not provide an export named 'PostgresError'
7 replies
TTCTheo's Typesafe Cult
Created by barry on 11/30/2023 in #questions
drizzle + express + ts errors
https://gist.github.com/barrybtw/67c379371c3f52a61758c94474e8ebf8 In regards to the route auth_router.post("/signup", () => ...), I get this error
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:393:5)
at ServerResponse.setHeader (node:_http_outgoing:644:11)
at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:393:5)
at ServerResponse.setHeader (node:_http_outgoing:644:11)
at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
I don't seem to be breaking that so a bit confused? And if I use a username that's already taken (username has the unique constraint) I get this error PostgresError: duplicate key value violates unique constraint "user_username_unique", and I can't import the type PostgresError as it's not exported but it's part of the types in the node modules, yet I can't import it without runtime errors. SyntaxError: The requested module 'postgres' does not provide an export named 'PostgresError'
4 replies
TTCTheo's Typesafe Cult
Created by barry on 11/29/2023 in #questions
Leetcode Geniuses please explain
https://leetcode.com/problems/kids-with-the-greatest-number-of-candies THIS WORKS, OK?
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let max = Math.max(...candies);
return candies.map((kid) => kid + extraCandies >= max)
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let max = Math.max(...candies);
return candies.map((kid) => kid + extraCandies >= max)
};
SOMEHOW THIS DOESN'T WORK WTF!!?
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (const kid in candies) {
result.push((kid + extraCandies) >= max)
}
return result
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (const kid in candies) {
result.push((kid + extraCandies) >= max)
}
return result
};
YET THIS WORKS???
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (let j = 0; j < candies.length; j++) {
result.push((candies[j] + extraCandies) >= max)
}
return result
};
function kidsWithCandies(candies: number[], extraCandies: number): boolean[] {
let result = []
let max = Math.max(...candies);
for (let j = 0; j < candies.length; j++) {
result.push((candies[j] + extraCandies) >= max)
}
return result
};
3 replies
TTCTheo's Typesafe Cult
Created by barry on 8/14/2023 in #questions
drizzle many-to-many
https://gist.github.com/barrybtw/f4c54bf7bdac98af34069363d7b1be87 Trying to setup a many-to-many relationship between calendar and user. But I'm getting some weird Typescript errors.
Argument of type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is not assignable to parameter of type 'Table<TableConfig$3<Column<any, object, object>>>'.ts(2345)
Argument of type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is not assignable to parameter of type 'Table<TableConfig$3<Column<any, object, object>>>'.
Type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is missing the following properties from type 'Table<TableConfig$3<Column<any, object, object>>>': _, getSQL, [IsDrizzleTable]ts(2345)
Argument of type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is not assignable to parameter of type 'Table<TableConfig$3<Column<any, object, object>>>'.ts(2345)
Argument of type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is not assignable to parameter of type 'Table<TableConfig$3<Column<any, object, object>>>'.
Type 'Relations<"calendar_participant", { calendar: One<"calendar", true>; user: One<"user", true>; }>' is missing the following properties from type 'Table<TableConfig$3<Column<any, object, object>>>': _, getSQL, [IsDrizzleTable]ts(2345)
6 replies
TTCTheo's Typesafe Cult
Created by barry on 8/13/2023 in #questions
Include txt into tsc build
I have a ascii.txt file which I read with fs since formatting it correctly in a ts file is a nightmare How do I include it in the build
16 replies
TTCTheo's Typesafe Cult
Created by barry on 8/12/2023 in #questions
[tsup] making a package
Error: Command failed: taskkill /pid 13244 /T /F
ERROR: The process "13244" not found.

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5)
Error: Command failed: taskkill /pid 13244 /T /F
ERROR: The process "13244" not found.

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5)
4 replies
DTDrizzle Team
Created by barry on 8/7/2023 in #help
Weird type errors when running code
3 replies
TTCTheo's Typesafe Cult
Created by barry on 8/7/2023 in #questions
Drizzle type question
I swapped over to Drizzle, and I've got this schema right
export const User = mysqlTable('users', {
id: serial('id').primaryKey(),
username: text('username').unique(),
passwordHash: text('password_hash'),
passwordSalt: text('password_salt'),
role: mysqlEnum('role', ['user', 'admin']),
createdAt: timestamp('created_at').notNull().default(new Date()),
updatedAt: timestamp('updated_at').notNull().default(new Date()),
});
export const Session = mysqlTable('sessions', {
id: serial('id').primaryKey(),
token: text('token').unique(),
csrfToken: text('csrf_token'),
expiresAt: timestamp('expires_at').notNull(),
userid: int('user_id').references(() => User.id),
});
export const User = mysqlTable('users', {
id: serial('id').primaryKey(),
username: text('username').unique(),
passwordHash: text('password_hash'),
passwordSalt: text('password_salt'),
role: mysqlEnum('role', ['user', 'admin']),
createdAt: timestamp('created_at').notNull().default(new Date()),
updatedAt: timestamp('updated_at').notNull().default(new Date()),
});
export const Session = mysqlTable('sessions', {
id: serial('id').primaryKey(),
token: text('token').unique(),
csrfToken: text('csrf_token'),
expiresAt: timestamp('expires_at').notNull(),
userid: int('user_id').references(() => User.id),
});
And I'm trying to get a session based on an id coming from the client
const session = await db
.select()
.from(Session)
.where(eq(Session.token, sessionToken))
.innerJoin(User, eq(Session.userid, User.id)).limit(1)
.execute();
const session = await db
.select()
.from(Session)
.where(eq(Session.token, sessionToken))
.innerJoin(User, eq(Session.userid, User.id)).limit(1)
.execute();
This seems right, right? But why in the world is the type of session an array consisting of an object with a users and sessions prop?
session: {
sessions: {
id: number;
token: string | null;
csrfToken: string | null;
expiresAt: Date;
userid: number | null;
};
users: {
id: number;
username: string | null;
passwordHash: string | null;
passwordSalt: string | null;
role: "user" | ... 1 more ... | null;
createdAt: Date;
updatedAt: Date;
};
}[]
session: {
sessions: {
id: number;
token: string | null;
csrfToken: string | null;
expiresAt: Date;
userid: number | null;
};
users: {
id: number;
username: string | null;
passwordHash: string | null;
passwordSalt: string | null;
role: "user" | ... 1 more ... | null;
createdAt: Date;
updatedAt: Date;
};
}[]
10 replies
TTCTheo's Typesafe Cult
Created by barry on 8/5/2023 in #questions
framer motion stuff
So I've got this title thingy
'use client';

import { bodoni_moda } from '@/lib/fonts';
import { cn } from '@/lib/utils';
import {
motion,
useTransform,
useMotionValueEvent,
useScroll,
} from 'framer-motion';
export default function HeroTitle({
className,
...props
}: React.HTMLAttributes<HTMLElement>) {
const { scrollYProgress } = useScroll();
const marginLeft = useTransform(scrollYProgress, [0, 1], ['5%', '35%']);
return (
<motion.h1
className={cn(
bodoni_moda.className,
'break-all text-5xl sm:text-7xl lg:text-9xl w-full leading-[1.15] md:leading-[1.25] lg:leading-[1.35] uppercase',
)}
>
<motion.span style={{ marginLeft }}>J</motion.span>
ust simple and elegant authentication in your hands
</motion.h1>
);
}
'use client';

import { bodoni_moda } from '@/lib/fonts';
import { cn } from '@/lib/utils';
import {
motion,
useTransform,
useMotionValueEvent,
useScroll,
} from 'framer-motion';
export default function HeroTitle({
className,
...props
}: React.HTMLAttributes<HTMLElement>) {
const { scrollYProgress } = useScroll();
const marginLeft = useTransform(scrollYProgress, [0, 1], ['5%', '35%']);
return (
<motion.h1
className={cn(
bodoni_moda.className,
'break-all text-5xl sm:text-7xl lg:text-9xl w-full leading-[1.15] md:leading-[1.25] lg:leading-[1.35] uppercase',
)}
>
<motion.span style={{ marginLeft }}>J</motion.span>
ust simple and elegant authentication in your hands
</motion.h1>
);
}
I add some margin to make it move to the side when scrolling which works, but it's obviously very jumpy? It's not smooth moving the whole thing around
2 replies
TTCTheo's Typesafe Cult
Created by barry on 8/1/2023 in #questions
[possiblo?] i made this garbage code, can you make it better
https://github.com/barrybtw/aktiesparekonto/blob/master/lib/calculate.ts just lets me know how much money i'd have after x years, how much is profit, how much will be paid in tax, the code is ugly as hell but i dont think it can get better, but maybe someone in here is the einstein of coding and maths
1 replies
TTCTheo's Typesafe Cult
Created by barry on 7/28/2023 in #questions
[shadcn/ui] hydration error with labels not being directed right?
4 replies
TTCTheo's Typesafe Cult
Created by barry on 7/28/2023 in #questions
[SHADCN/UI] Form Input add symbol
5 replies
TTCTheo's Typesafe Cult
Created by barry on 7/28/2023 in #questions
[SHADCN/UI] Toaster Hydration Issues...
7 replies
TTCTheo's Typesafe Cult
Created by barry on 3/26/2023 in #questions
tRPC cookies
Anyone know how to set a cookie with trpc?
6 replies