diff --git a/drizzle.config.ts b/drizzle.config.ts index ff8044a..a77c661 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -1,14 +1,13 @@ import { defineConfig } from 'drizzle-kit'; -if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set'); +if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set (drizzle_config)'); export default defineConfig({ + dialect: 'postgresql', schema: './src/lib/server/db/schema.ts', out: './drizzle', dbCredentials: { - url: process.env.DATABASE_URL, - ssl: true + url: process.env.DATABASE_URL }, verbose: true, - strict: true, - dialect: 'postgresql' + strict: true }); diff --git a/package.json b/package.json index 620854b..22cd3f4 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "@types/codemirror": "^5.60.15", "@types/lodash": "^4.17.16", "@types/node": "^22.10.2", + "@types/pg": "^8.11.13", "amplify-adapter": "^0.2.0", "autoprefixer": "^10.4.20", "dotenv": "^16.4.7", @@ -77,6 +78,7 @@ "html2canvas": "^1.4.1", "lodash-es": "^4.17.21", "lottie-web": "^5.12.2", + "pg": "^8.14.1", "pnpm": "^10.2.1", "postgres": "^3.4.5", "svelte-codemirror-editor": "^1.4.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4f7340..7c8ed6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,6 +83,9 @@ importers: lottie-web: specifier: ^5.12.2 version: 5.12.2 + pg: + specifier: ^8.14.1 + version: 8.14.1 pnpm: specifier: ^10.2.1 version: 10.5.2 @@ -123,6 +126,9 @@ importers: '@types/node': specifier: ^22.10.2 version: 22.13.5 + '@types/pg': + specifier: ^8.11.13 + version: 8.11.13 amplify-adapter: specifier: ^0.2.0 version: 0.2.0(@sveltejs/kit@2.17.3(@sveltejs/vite-plugin-svelte@5.0.3(svelte@5.20.5)(vite@6.2.0(@types/node@22.13.5)(jiti@1.21.7)(yaml@2.7.0)))(svelte@5.20.5)(vite@6.2.0(@types/node@22.13.5)(jiti@1.21.7)(yaml@2.7.0))) @@ -2095,9 +2101,6 @@ packages: resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==} engines: {node: '>= 0.6.0'} - base64-js@1.5.1: - resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - before-after-hook@2.2.3: resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} @@ -2746,22 +2749,10 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} - hast-util-to-html@9.0.5: - resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==} - - hast-util-whitespace@3.0.0: - resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==} - - html-void-elements@3.0.0: - resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} - html2canvas@1.4.1: resolution: {integrity: sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==} engines: {node: '>=8.0.0'} - ieee754@1.2.1: - resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} - ignore@5.3.1: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} @@ -5377,7 +5368,6 @@ snapshots: '@types/node': 22.13.5 pg-protocol: 1.8.0 pg-types: 4.0.2 - optional: true '@types/pg@8.11.6': dependencies: @@ -5607,8 +5597,6 @@ snapshots: base64-arraybuffer@1.0.2: {} - base64-js@1.5.1: {} - before-after-hook@2.2.3: {} binary-extensions@2.3.0: {} @@ -6290,33 +6278,11 @@ snapshots: dependencies: function-bind: 1.1.2 - hast-util-to-html@9.0.5: - dependencies: - '@types/hast': 3.0.4 - '@types/unist': 3.0.3 - ccount: 2.0.1 - comma-separated-tokens: 2.0.3 - hast-util-whitespace: 3.0.0 - html-void-elements: 3.0.0 - mdast-util-to-hast: 13.2.0 - property-information: 7.0.0 - space-separated-tokens: 2.0.2 - stringify-entities: 4.0.4 - zwitch: 2.0.4 - - hast-util-whitespace@3.0.0: - dependencies: - '@types/hast': 3.0.4 - - html-void-elements@3.0.0: {} - html2canvas@1.4.1: dependencies: css-line-break: 2.1.0 text-segmentation: 1.0.3 - ieee754@1.2.1: {} - ignore@5.3.1: {} ignore@5.3.2: {} @@ -6576,8 +6542,7 @@ snapshots: object-hash@3.0.0: {} - obuf@1.1.2: - optional: true + obuf@1.1.2: {} octokit@3.1.2: dependencies: @@ -6645,22 +6610,17 @@ snapshots: pg-cloudflare@1.1.1: optional: true - pg-connection-string@2.7.0: - optional: true + pg-connection-string@2.7.0: {} - pg-int8@1.0.1: - optional: true + pg-int8@1.0.1: {} - pg-numeric@1.0.2: - optional: true + pg-numeric@1.0.2: {} pg-pool@3.8.0(pg@8.14.1): dependencies: pg: 8.14.1 - optional: true - pg-protocol@1.8.0: - optional: true + pg-protocol@1.8.0: {} pg-types@2.2.0: dependencies: @@ -6669,7 +6629,6 @@ snapshots: postgres-bytea: 1.0.0 postgres-date: 1.0.7 postgres-interval: 1.2.0 - optional: true pg-types@4.0.2: dependencies: @@ -6680,7 +6639,6 @@ snapshots: postgres-date: 2.1.0 postgres-interval: 3.0.0 postgres-range: 1.1.4 - optional: true pg@8.14.1: dependencies: @@ -6691,12 +6649,10 @@ snapshots: pgpass: 1.0.5 optionalDependencies: pg-cloudflare: 1.1.1 - optional: true pgpass@1.0.5: dependencies: split2: 4.2.0 - optional: true picocolors@1.1.1: {} @@ -6775,36 +6731,27 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - postgres-array@2.0.0: - optional: true + postgres-array@2.0.0: {} - postgres-array@3.0.2: - optional: true + postgres-array@3.0.2: {} - postgres-bytea@1.0.0: - optional: true + postgres-bytea@1.0.0: {} postgres-bytea@3.0.0: dependencies: obuf: 1.1.2 - optional: true - postgres-date@1.0.7: - optional: true + postgres-date@1.0.7: {} - postgres-date@2.1.0: - optional: true + postgres-date@2.1.0: {} postgres-interval@1.2.0: dependencies: xtend: 4.0.2 - optional: true - postgres-interval@3.0.0: - optional: true + postgres-interval@3.0.0: {} - postgres-range@1.1.4: - optional: true + postgres-range@1.1.4: {} postgres@3.4.5: {} @@ -6999,8 +6946,7 @@ snapshots: sourcemap-codec@1.4.8: {} - split2@4.2.0: - optional: true + split2@4.2.0: {} stackback@0.0.2: {} @@ -7374,8 +7320,7 @@ snapshots: ws@8.18.0: {} - xtend@4.0.2: - optional: true + xtend@4.0.2: {} yaml@1.10.2: {} diff --git a/src/auth.ts b/src/auth.ts index d51d3e1..7e1cab6 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,7 +1,7 @@ import { SvelteKitAuth } from '@auth/sveltekit'; import GitHub from '@auth/sveltekit/providers/github'; import Google from '@auth/sveltekit/providers/google'; -import { GITHUB_ID, GITHUB_SECRET, GOOGLE_ID, GOOGLE_SECRET } from '$env/static/private'; +import { env } from '$env/dynamic/private'; import { DrizzleAdapter } from '@auth/drizzle-adapter'; import { users, @@ -13,11 +13,6 @@ import { import { eq } from 'drizzle-orm'; import { db } from '$lib/server/db'; -const githubId = GITHUB_ID || process.env.GITHUB_ID; -const githubSecret = GITHUB_SECRET || process.env.GITHUB_SECRET; -const googleId = GOOGLE_ID || process.env.GOOGLE_ID; -const googleSecret = GOOGLE_SECRET || process.env.GOOGLE_SECRET; - export const { handle: handleAuth, signIn, @@ -63,13 +58,14 @@ export const { }, providers: [ GitHub({ - clientId: githubId, - clientSecret: githubSecret + clientId: env.GITHUB_ID, + clientSecret: env.GITHUB_SECRET }), Google({ - clientId: googleId, - clientSecret: googleSecret + clientId: env.GOOGLE_ID, + clientSecret: env.GOOGLE_SECRET }) ], - trustHost: true + trustHost: env.AUTH_TRUST_HOST === 'true' || process.env.AUTH_TRUST_HOST === 'true', + secret: env.AUTH_SECRET }); diff --git a/src/lib/server/db.ts b/src/lib/server/db.ts index baa2fe5..2ff1ac9 100644 --- a/src/lib/server/db.ts +++ b/src/lib/server/db.ts @@ -8,7 +8,7 @@ const dbUrl = env.DATABASE_URL || 'postgres://postgres:postgres@hungrystack-db.cjcg24aqon9g.us-east-2.rds.amazonaws.com:5432/hungrystackdb'; -if (!dbUrl) throw new Error('DATABASE_URL is required'); +if (!dbUrl) throw new Error('DATABASE_URL is required (db-ts)'); const client = postgres(dbUrl, { ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: true } : false diff --git a/svelte.config.js b/svelte.config.js index eb9d599..42c674f 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -14,7 +14,11 @@ const config = { // See https://svelte.dev/docs/kit/adapters for more information about adapters. adapter: adapter({ output: 'minimal' - }) + }), + env: { + publicPrefix: 'PUBLIC_', + privatePrefix: '' + } }, extensions: ['.svelte', '.svx']