commits frfr
This commit is contained in:
parent
e0b483f344
commit
dcc647d085
6 changed files with 64 additions and 23 deletions
|
@ -1,11 +1,14 @@
|
|||
import { defineConfig } from 'drizzle-kit';
|
||||
|
||||
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||
|
||||
export default defineConfig({
|
||||
schema: './src/lib/server/db/schema.ts',
|
||||
dbCredentials: { url: process.env.DATABASE_URL },
|
||||
dbCredentials: {
|
||||
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
|
||||
databaseId: process.env.CLOUDFLARE_DATABASE_ID!,
|
||||
token: process.env.CLOUDFLARE_D1_TOKEN!,
|
||||
},
|
||||
verbose: true,
|
||||
strict: true,
|
||||
dialect: 'sqlite'
|
||||
dialect: 'sqlite',
|
||||
driver: 'd1-http'
|
||||
});
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"test": "npm run test:unit -- --run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20250403.0",
|
||||
"@eslint/compat": "^1.2.5",
|
||||
"@eslint/js": "^9.18.0",
|
||||
"@sveltejs/adapter-cloudflare": "^5.0.1",
|
||||
|
@ -46,7 +47,6 @@
|
|||
"vitest": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@libsql/client": "^0.14.0",
|
||||
"drizzle-orm": "^0.40.0"
|
||||
},
|
||||
"pnpm": {
|
||||
|
|
39
pnpm-lock.yaml
generated
39
pnpm-lock.yaml
generated
|
@ -8,13 +8,13 @@ importers:
|
|||
|
||||
.:
|
||||
dependencies:
|
||||
'@libsql/client':
|
||||
specifier: ^0.14.0
|
||||
version: 0.14.0
|
||||
drizzle-orm:
|
||||
specifier: ^0.40.0
|
||||
version: 0.40.1(@cloudflare/workers-types@4.20250403.0)(@libsql/client@0.14.0)(gel@2.0.1)
|
||||
devDependencies:
|
||||
'@cloudflare/workers-types':
|
||||
specifier: ^4.20250403.0
|
||||
version: 4.20250403.0
|
||||
'@eslint/compat':
|
||||
specifier: ^1.2.5
|
||||
version: 1.2.8(eslint@9.23.0(jiti@2.4.2))
|
||||
|
@ -3402,10 +3402,12 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
'@libsql/core@0.14.0':
|
||||
dependencies:
|
||||
js-base64: 3.7.7
|
||||
optional: true
|
||||
|
||||
'@libsql/darwin-arm64@0.4.7':
|
||||
optional: true
|
||||
|
@ -3422,8 +3424,10 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
'@libsql/isomorphic-fetch@0.3.1': {}
|
||||
'@libsql/isomorphic-fetch@0.3.1':
|
||||
optional: true
|
||||
|
||||
'@libsql/isomorphic-ws@0.1.5':
|
||||
dependencies:
|
||||
|
@ -3432,6 +3436,7 @@ snapshots:
|
|||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- utf-8-validate
|
||||
optional: true
|
||||
|
||||
'@libsql/linux-arm64-gnu@0.4.7':
|
||||
optional: true
|
||||
|
@ -3448,7 +3453,8 @@ snapshots:
|
|||
'@libsql/win32-x64-msvc@0.4.7':
|
||||
optional: true
|
||||
|
||||
'@neon-rs/load@0.0.4': {}
|
||||
'@neon-rs/load@0.0.4':
|
||||
optional: true
|
||||
|
||||
'@nodelib/fs.scandir@2.1.5':
|
||||
dependencies:
|
||||
|
@ -3682,6 +3688,7 @@ snapshots:
|
|||
'@types/ws@8.18.1':
|
||||
dependencies:
|
||||
'@types/node': 22.14.0
|
||||
optional: true
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.29.0(@typescript-eslint/parser@8.29.0(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2))(eslint@9.23.0(jiti@2.4.2))(typescript@5.8.2)':
|
||||
dependencies:
|
||||
|
@ -3944,7 +3951,8 @@ snapshots:
|
|||
|
||||
data-uri-to-buffer@2.0.2: {}
|
||||
|
||||
data-uri-to-buffer@4.0.1: {}
|
||||
data-uri-to-buffer@4.0.1:
|
||||
optional: true
|
||||
|
||||
data-urls@5.0.0:
|
||||
dependencies:
|
||||
|
@ -3969,7 +3977,8 @@ snapshots:
|
|||
|
||||
dequal@2.0.3: {}
|
||||
|
||||
detect-libc@2.0.2: {}
|
||||
detect-libc@2.0.2:
|
||||
optional: true
|
||||
|
||||
detect-libc@2.0.3: {}
|
||||
|
||||
|
@ -4279,6 +4288,7 @@ snapshots:
|
|||
dependencies:
|
||||
node-domexception: 1.0.0
|
||||
web-streams-polyfill: 3.3.3
|
||||
optional: true
|
||||
|
||||
file-entry-cache@8.0.0:
|
||||
dependencies:
|
||||
|
@ -4310,6 +4320,7 @@ snapshots:
|
|||
formdata-polyfill@4.0.10:
|
||||
dependencies:
|
||||
fetch-blob: 3.2.0
|
||||
optional: true
|
||||
|
||||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
@ -4444,7 +4455,8 @@ snapshots:
|
|||
|
||||
jiti@2.4.2: {}
|
||||
|
||||
js-base64@3.7.7: {}
|
||||
js-base64@3.7.7:
|
||||
optional: true
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
|
@ -4511,6 +4523,7 @@ snapshots:
|
|||
'@libsql/linux-x64-gnu': 0.4.7
|
||||
'@libsql/linux-x64-musl': 0.4.7
|
||||
'@libsql/win32-x64-msvc': 0.4.7
|
||||
optional: true
|
||||
|
||||
lightningcss-darwin-arm64@1.29.2:
|
||||
optional: true
|
||||
|
@ -4635,13 +4648,15 @@ snapshots:
|
|||
|
||||
natural-compare@1.4.0: {}
|
||||
|
||||
node-domexception@1.0.0: {}
|
||||
node-domexception@1.0.0:
|
||||
optional: true
|
||||
|
||||
node-fetch@3.3.2:
|
||||
dependencies:
|
||||
data-uri-to-buffer: 4.0.1
|
||||
fetch-blob: 3.2.0
|
||||
formdata-polyfill: 4.0.10
|
||||
optional: true
|
||||
|
||||
nwsapi@2.2.20: {}
|
||||
|
||||
|
@ -4735,7 +4750,8 @@ snapshots:
|
|||
|
||||
printable-characters@1.0.42: {}
|
||||
|
||||
promise-limit@2.7.0: {}
|
||||
promise-limit@2.7.0:
|
||||
optional: true
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
|
@ -5084,7 +5100,8 @@ snapshots:
|
|||
dependencies:
|
||||
xml-name-validator: 5.0.0
|
||||
|
||||
web-streams-polyfill@3.3.3: {}
|
||||
web-streams-polyfill@3.3.3:
|
||||
optional: true
|
||||
|
||||
webidl-conversions@7.0.0: {}
|
||||
|
||||
|
|
12
src/app.d.ts
vendored
12
src/app.d.ts
vendored
|
@ -1,3 +1,5 @@
|
|||
import type { D1Database, CacheStorage, Cache } from '@cloudflare/workers-types';
|
||||
|
||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
|
@ -6,7 +8,15 @@ declare global {
|
|||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
interface Platform {
|
||||
env?: {
|
||||
HANDLES_DB: D1Database;
|
||||
}
|
||||
context: {
|
||||
waitUntil(promise: Promise<unknown>): void;
|
||||
};
|
||||
caches: CacheStorage & { default: Cache };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import { drizzle } from 'drizzle-orm/libsql';
|
||||
import { createClient } from '@libsql/client';
|
||||
import { drizzle } from 'drizzle-orm/d1';
|
||||
import * as schema from './schema';
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||
console.log(env.HANDLES_DB)
|
||||
|
||||
const client = createClient({ url: env.DATABASE_URL });
|
||||
|
||||
export const db = drizzle(client, { schema });
|
||||
export const db = drizzle(env.HANDLES_DB, { schema });
|
||||
|
|
14
wrangler.toml
Normal file
14
wrangler.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
name = "protogen-social-handles"
|
||||
compatibility_date = "2025-01-01"
|
||||
compatibility_flags = [ "nodejs_compat" ]
|
||||
pages_build_output_dir = ".svelte-kit/cloudflare"
|
||||
|
||||
[[ env.production.d1_databases ]]
|
||||
binding = "HANDLES_DB"
|
||||
database_name = "production-protogen-social-handles"
|
||||
database_id = "b7e2740b-9f80-4a0a-b641-a1802339af67"
|
||||
|
||||
[[ env.preview.d1_databases ]]
|
||||
binding = "HANDLES_DB"
|
||||
database_name = "preview-protogen-social-handles"
|
||||
database_id = "9edbeba1-cec2-4f91-800f-5b82cb727717"
|
Loading…
Add table
Add a link
Reference in a new issue