Silvan
Silvan
Explore posts from servers
DTDrizzle Team
Created by Silvan on 3/26/2025 in #help
Durable Object example weird import
Here in thd docs https://orm.drizzle.team/docs/connect-cloudflare-do There is the following import import migrations from '../drizzle/migrations'; which i dont get? Inside my drizzle folder i have the migration files .sql and a meta folder. Where does the migrations file come from? I did see the We need rules so we can import migrations in the next steps ```toml [[rules]] type = "Text" globs = ["**/.sql"] fallthrough = true ``` But do i need to run some command first?
11 replies
CDCloudflare Developers
Created by Silvan on 2/27/2025 in #workers-help
D1 adding more latency than expected
Im using sveltekit and i created 2 test routes. they essentially do the same but one does a select 1; in d1. When warm the the difference in response time is 50ms which just seems super high considering the query takes less than 1ms. I chose the cloest location to me when i created d1 I use workers with assets. here the code for both api endpoints i used to just test it out Is this really the expected behaviour? No Db:
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async () => {
const uuid = crypto.randomUUID();
return new Response(uuid);
};
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async () => {
const uuid = crypto.randomUUID();
return new Response(uuid);
};
With D1:
import { drizzle } from 'drizzle-orm/d1';
import { sql } from 'drizzle-orm';
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async ({ platform }) => {
const db = drizzle(platform!.env.DB);
await db.run(sql`SELECT 1`);
const uuid = crypto.randomUUID();
return new Response(uuid);
};
import { drizzle } from 'drizzle-orm/d1';
import { sql } from 'drizzle-orm';
import type { RequestHandler } from './$types';

export const GET: RequestHandler = async ({ platform }) => {
const db = drizzle(platform!.env.DB);
await db.run(sql`SELECT 1`);
const uuid = crypto.randomUUID();
return new Response(uuid);
};
i tried without drizzle as well but i dont see a difference
5 replies
CDCloudflare Developers
Created by Silvan on 2/24/2025 in #workers-help
How to debug "EvalError: Code generation from strings disallowed for this context"
Im aware that this is caused by eval and new Function. i moved my entire validation to https://www.npmjs.com/package/@cfworker/json-schema because i thought it was that. but it wasnt im using worker assets with sveltekit. i checked the _workers.js but its really small and no eval or new Function there
4 replies
BABetter Auth
Created by Silvan on 2/19/2025 in #help
DrizzleThe model "verification" was not found in the schema object. Please pass the schema
I just followed the installation + sveltekit guide. Clicking the login action gives me a 500 on http://localhost:5173/api/auth/sign-in/social Server error is ERROR [Better Auth]: BetterAuthError [BetterAuthError: [# Drizzle Adapter]: The model "verification" was not found in the schema object. Please pass the schema directly to the adapter options.] { cause: undefined } the tables exist i can query them too.
9 tables
account 13 columns 0 indexes 1 fks
appointment 8 columns 0 indexes 3 fks
customer 8 columns 0 indexes 0 fks
employee 2 columns 0 indexes 0 fks
service 3 columns 0 indexes 0 fks
session 8 columns 1 indexes 1 fks
shiftPlan 18 columns 0 indexes 1 fks
user 7 columns 1 indexes 0 fks
verification 6 columns 0 indexes 0 fks
9 tables
account 13 columns 0 indexes 1 fks
appointment 8 columns 0 indexes 3 fks
customer 8 columns 0 indexes 0 fks
employee 2 columns 0 indexes 0 fks
service 3 columns 0 indexes 0 fks
session 8 columns 1 indexes 1 fks
shiftPlan 18 columns 0 indexes 1 fks
user 7 columns 1 indexes 0 fks
verification 6 columns 0 indexes 0 fks
my hooks.server.ts
const originalHandle: Handle = async ({ event, resolve }) => {
const locale = languageTag();
dayjs.locale(locale);
const response = await resolve(event);
return response;
};

const authHandle: Handle = async ({ event, resolve }) => {
return svelteKitHandler({ event, resolve, auth });
};

const handleParaglide: Handle = i18n.handle();

export const handle = sequence(authHandle, handleParaglide, originalHandle);
const originalHandle: Handle = async ({ event, resolve }) => {
const locale = languageTag();
dayjs.locale(locale);
const response = await resolve(event);
return response;
};

const authHandle: Handle = async ({ event, resolve }) => {
return svelteKitHandler({ event, resolve, auth });
};

const handleParaglide: Handle = i18n.handle();

export const handle = sequence(authHandle, handleParaglide, originalHandle);
now it asks me to pass the schema. but drizzle schemas are usually just exported tables. theres no default export or what am i missing?
4 replies
BABetter Auth
Created by Silvan on 1/29/2025 in #help
CLI cant generate using SvelteKits $app import
So i just followed the guide. when i tried generating the db things i run into ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: Cannot find module '$app/environment'
import { dev } from '$app/environment';
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
import { env } from '$env/dynamic/private';

if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error('DATABASE_AUTH_TOKEN is not set');

const client = createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN });
export const db = drizzle(client);
import { dev } from '$app/environment';
import { drizzle } from 'drizzle-orm/libsql';
import { createClient } from '@libsql/client';
import { env } from '$env/dynamic/private';

if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error('DATABASE_AUTH_TOKEN is not set');

const client = createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN });
export const db = drizzle(client);
not entirely sure why this dosent work in the cli? i could use vite env stuff but still weird error imo
4 replies
CDCloudflare Developers
Created by Silvan on 1/12/2025 in #pages-help
Recommended Project structure for Pages + Durable Objects + ..
So im currently running into the issue that i cant really get sveltekit + durable objects up. I used the cf starter cli for sveltekit that worked all fine. but as soon as i add the do binding and run dev again i get no response. I have a DoClass exported somewhere in my project but i feel like its just wrong. I found this repo. In his case he splits the Pages with the Worker based things (monorepo). Is this the recommended approach? https://github.com/harshil1712/votes-app-demo
6 replies
DTDrizzle Team
Created by Silvan on 11/5/2024 in #help
How to set PRAMGA for Sqlite
Really not sure how this would be done here. Some of them are permanent but some need to be set on every connection. in my example something like: PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL; PRAGMA mmap_size = 134217728; PRAGMA journal_size_limit = 67108864; PRAGMA cache_size = -2000; Where would i set these?
4 replies
CC#
Created by Silvan on 5/30/2024 in #help
Recommendation for handling logging in a API
No description
1 replies
SSolidJS
Created by Silvan on 11/15/2023 in #support
Nested Routing
No description
9 replies
SSolidJS
Created by Silvan on 4/9/2023 in #support
React user confused on how to work with createResource response
Hey Guys i feel like im missing a fundamental thing here. it works but it looks very weird. Is there a better pattern for this? Basically data is an Array. I now want 1 random children to display
4 replies
SSolidJS
Created by Silvan on 3/31/2023 in #support
Get simple fetch data to render
17 replies