Derock
Derock
Explore posts from servers
TtRPC
Created by Derock on 6/3/2024 in #❓-help
is it possible to send error codes that aren't listed (eg 503 - service unavailable)
When creating a TRPCError you can specify a code out of the ones listed on the docs But out of these, the only 5xx error is internal server error. I would like to send a 503 to indicate that the request was properly formatted, but the server isn't ready to handle it yet. It's not necessarily a server error.
2 replies
DTDrizzle Team
Created by Derock on 5/15/2024 in #help
need help with drizzle transactions and foreign key constraints
No description
8 replies
DTDrizzle Team
Created by Derock on 4/28/2024 in #help
cannot migrate database: PostgresError: unterminated /* comment at or near "/*
No description
1 replies
DTDrizzle Team
Created by Derock on 4/27/2024 in #help
ts: Object literal may only specify known properties except the property is known
No description
5 replies
DTDrizzle Team
Created by Derock on 4/23/2024 in #help
SQLite: set fk constraint to be "DEFERRABLE INITIALLY DEFERRED"
I would like to use this feature of sqlite, but I don't see it mentioned anywhere in the docs. A quick search shows that there's an open issue (#1429) but no progress has been made. Are there any temporary workarounds to this? Like can I add in my own SQL to the end of a column definition?
3 replies
TtRPC
Created by Derock on 1/13/2024 in #❓-help
is there a way to send a streaming response
I'm not talking about batching multiple requests, but more of a one-way websocket-like channel between the server and client using HTTP streaming.
6 replies
DTDrizzle Team
Created by Derock on 12/19/2023 in #help
`no such table: main.__old_push_projects` after db push
Added the following to a table named service:
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
and ran pnpm drizzle-kit push:sqlite it warned:
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
__old_push_projects is never mentioned in my codebase. I have a table named projects, and thats the closest thing. now my server errors with:
"no such table: main.__old_push_projects"
What is this table supposed to be and how can I get it back?
19 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
I have an application, and on certain pages I need live data. Is there a way to only have tRPC open a websocket for subscriptions and then use another link otherwise? I would like for the solution to disconnect from WS when all subscriptions have been ended, so no dangling WS connections.
15 replies
TtRPC
Created by Derock on 11/4/2023 in #❓-help
How to set cookies in trpc response?
I have an app dir project that was created using this t3-app PR. On the client I have a form and I am using the trpc react client:
import { api } from "~/trpc/react";
[...]
const login = api.auth.login.useMutation({ ... });
import { api } from "~/trpc/react";
[...]
const login = api.auth.login.useMutation({ ... });
and I have the following route defined:
import { cookies } from "next/headers";

publicProcedure
.input(...)
.mutation(async ({ ctx, input }) => {
[...]

// somehow set a cookie
cookies().set("session", session.data.token, {
httpOnly: true,
});

[...]
}),
import { cookies } from "next/headers";

publicProcedure
.input(...)
.mutation(async ({ ctx, input }) => {
[...]

// somehow set a cookie
cookies().set("session", session.data.token, {
httpOnly: true,
});

[...]
}),
This does not set the cookie though -- no Set-Cookie header is in the response. I have no idea how to access the response manually to add the header in either.
11 replies
DTDrizzle Team
Created by Derock on 11/2/2023 in #help
How do I load sqlite extensions for drizzle-kit?
In my code, when I want to use drizzle I am doing the following:
const sqlite = new SQLite3(env.DATABASE_PATH);

// enable WAL mode
sqlite.pragma("journal_mode = WAL");

// load uuidv7 extension
// built from https://github.com/craigpastro/sqlite-uuidv7
sqlite.loadExtension(
env.SQLITE_UUIDV7_EXT_PATH ??
join(__dirname, "../../../exts/sqlite-uuidv7.so"),
);

export const db = drizzle(sqlite);
const sqlite = new SQLite3(env.DATABASE_PATH);

// enable WAL mode
sqlite.pragma("journal_mode = WAL");

// load uuidv7 extension
// built from https://github.com/craigpastro/sqlite-uuidv7
sqlite.loadExtension(
env.SQLITE_UUIDV7_EXT_PATH ??
join(__dirname, "../../../exts/sqlite-uuidv7.so"),
);

export const db = drizzle(sqlite);
to test my application, I want to use drizzle-kit to create my database, so I created a drizzle.config.ts
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "better-sqlite",
dbCredentials: {
url: env.DATABASE_PATH,
},
} satisfies Config;
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "better-sqlite",
dbCredentials: {
url: env.DATABASE_PATH,
},
} satisfies Config;
but when I run drizzle-kit push:sqlite, I get SqliteError: near "(": syntax error and I think this is because for some of my tables I have .default(sql`uuid_generate_v7()`) but that function only exists when the sqlite extension is loaded which it isnt when Im running drizzle kit
4 replies
RRailway
Created by Derock on 5/10/2023 in #✋|help
how to install rustup with nixpacks?
Currently trying to deploy a moonrepo monorepo, but i am getting the following error: proto requires rustup to be installed and available on PATH to use Rust. Please install it and try again.
5 replies
TTCTheo's Typesafe Cult
Created by Derock on 4/16/2023 in #questions
NextAuth "[next-auth][error][JWT_SESSION_ERROR]" (CredentialsProvider)
This is my first time using next-auth, and I am trying to get basic credentials-based authentication implemenmted.
/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
profilePicture: string;
} & DefaultSession["user"];
}

interface User {
// ...other properties
// role: UserRole;
profilePicture: string;
}
}

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/
export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
secret: env.NEXTAUTH_SECRET!,
adapter: PrismaAdapter(prisma),
providers: [
CredentialsProvider({
name: "Credentials",

credentials: {
username: {
label: "Username",
type: "text",
},

password: {
label: "Password",
type: "password"
}
},

authorize: async (credentials, req) => {
return {
id: "1",
name: "John Smith",
profilePicture: "https://avatars.githubusercontent.com/u/1016365?v=4"
}
} // placeholder for now ^ - trying to rule out as many possible errors as i can
],

session: {
strategy: "jwt"
}
};

/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = (ctx: {
req: GetServerSidePropsContext["req"];
res: GetServerSidePropsContext["res"];
}) => {
return getServerSession(ctx.req, ctx.res, authOptions);
};
/**
* Module augmentation for `next-auth` types. Allows us to add custom properties to the `session`
* object and keep type safety.
*
* @see https://next-auth.js.org/getting-started/typescript#module-augmentation
*/
declare module "next-auth" {
interface Session extends DefaultSession {
user: {
id: string;
profilePicture: string;
} & DefaultSession["user"];
}

interface User {
// ...other properties
// role: UserRole;
profilePicture: string;
}
}

/**
* Options for NextAuth.js used to configure adapters, providers, callbacks, etc.
*
* @see https://next-auth.js.org/configuration/options
*/
export const authOptions: NextAuthOptions = {
callbacks: {
session: ({ session, user }) => ({
...session,
user: {
...session.user,
id: user.id,
},
}),
},
secret: env.NEXTAUTH_SECRET!,
adapter: PrismaAdapter(prisma),
providers: [
CredentialsProvider({
name: "Credentials",

credentials: {
username: {
label: "Username",
type: "text",
},

password: {
label: "Password",
type: "password"
}
},

authorize: async (credentials, req) => {
return {
id: "1",
name: "John Smith",
profilePicture: "https://avatars.githubusercontent.com/u/1016365?v=4"
}
} // placeholder for now ^ - trying to rule out as many possible errors as i can
],

session: {
strategy: "jwt"
}
};

/**
* Wrapper for `getServerSession` so that you don't need to import the `authOptions` in every file.
*
* @see https://next-auth.js.org/configuration/nextjs
*/
export const getServerAuthSession = (ctx: {
req: GetServerSidePropsContext["req"];
res: GetServerSidePropsContext["res"];
}) => {
return getServerSession(ctx.req, ctx.res, authOptions);
};
10 replies
RRailway
Created by Derock on 4/15/2023 in #✋|help
Is it possible to link two domains to one service, but have the ports different?
I am trying to deploy https://logto.io/ and it serves the public frontend on :3001 and the admin panel on :3002 How can I configure railway to have one domain forwarded to :3001 and another to :3002?
8 replies
RRailway
Created by Derock on 4/14/2023 in #✋|help
"Verify your account"
13 replies
SSolidJS
Created by Derock on 12/21/2022 in #support
solidjs not putting element in the correct spot.
9 replies