diff --git a/.vscode/launch.json b/.vscode/launch.json index e4199c01..306642ed 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -36,6 +36,13 @@ "program": "${workspaceFolder}/index.ts", "cwd": "${workspaceFolder}", "watchMode": true + }, + { + "type": "bun", + "internalConsoleOptions": "neverOpen", + "request": "launch", + "name": "Run tests", + "program": "test" } ] } diff --git a/api/api/v1/accounts/familiar_followers/index.ts b/api/api/v1/accounts/familiar_followers/index.ts index 0bc5c92f..180c6e89 100644 --- a/api/api/v1/accounts/familiar_followers/index.ts +++ b/api/api/v1/accounts/familiar_followers/index.ts @@ -88,7 +88,7 @@ export default apiRoute((app) => AND "IdsFollowers"."following" = true ) `) - ).rows.map((u) => u.id as string), + ).map((u) => u.id as string), ), })), ); diff --git a/bun.lock b/bun.lock index 81c8c467..31b5f513 100644 --- a/bun.lock +++ b/bun.lock @@ -48,7 +48,6 @@ "mitata": "^1.0.34", "oauth4webapi": "^3.5.0", "ora": "^8.2.0", - "pg": "^8.14.1", "qs": "^6.14.0", "sharp": "^0.34.1", "sonic-channel": "^1.3.1", @@ -68,7 +67,6 @@ "@types/html-to-text": "^9.0.4", "@types/markdown-it-container": "^2.0.10", "@types/mime-types": "^2.1.4", - "@types/pg": "^8.11.13", "@types/qs": "^6.9.18", "@types/web-push": "^3.6.4", "bun-bagel": "^1.2.0", diff --git a/drizzle/db.ts b/drizzle/db.ts index f1d67b9c..c4423eb6 100644 --- a/drizzle/db.ts +++ b/drizzle/db.ts @@ -1,13 +1,13 @@ import { getLogger } from "@logtape/logtape"; +import { SQL } from "bun"; import chalk from "chalk"; -import { drizzle, type NodePgDatabase } from "drizzle-orm/node-postgres"; +import { type BunSQLDatabase, drizzle } from "drizzle-orm/bun-sql"; import { withReplicas } from "drizzle-orm/pg-core"; import { migrate } from "drizzle-orm/postgres-js/migrator"; -import { Pool } from "pg"; import { config } from "~/config.ts"; import * as schema from "./schema.ts"; -const primaryDb = new Pool({ +const primaryDb = new SQL({ host: config.postgres.host, port: config.postgres.port, user: config.postgres.username, @@ -17,7 +17,7 @@ const primaryDb = new Pool({ const replicas = config.postgres.replicas.map( (replica) => - new Pool({ + new SQL({ host: replica.host, port: replica.port, user: replica.username, @@ -32,9 +32,9 @@ export const db = drizzle(primaryDb, { schema }), replicas.map((r) => drizzle(r, { schema })) as [ // biome-ignore lint/style/useNamingConvention: - NodePgDatabase & { $client: Pool }, + BunSQLDatabase & { $client: SQL }, // biome-ignore lint/style/useNamingConvention: - ...(NodePgDatabase & { $client: Pool })[], + ...(BunSQLDatabase & { $client: SQL })[], ], ) : drizzle(primaryDb, { schema }); diff --git a/package.json b/package.json index f5c672eb..315c2ad3 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "@types/html-to-text": "^9.0.4", "@types/markdown-it-container": "^2.0.10", "@types/mime-types": "^2.1.4", - "@types/pg": "^8.11.13", "@types/qs": "^6.9.18", "@types/web-push": "^3.6.4", "bun-bagel": "^1.2.0", @@ -127,7 +126,6 @@ "mitata": "^1.0.34", "oauth4webapi": "^3.5.0", "ora": "^8.2.0", - "pg": "^8.14.1", "qs": "^6.14.0", "sharp": "^0.34.1", "sonic-channel": "^1.3.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec5291ad..83444cae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -140,9 +140,6 @@ importers: ora: specifier: ^8.2.0 version: 8.2.0 - pg: - specifier: ^8.14.1 - version: 8.14.1 qs: specifier: ^6.14.0 version: 6.14.0 @@ -195,9 +192,6 @@ importers: '@types/mime-types': specifier: ^2.1.4 version: 2.1.4 - '@types/pg': - specifier: ^8.11.13 - version: 8.11.13 '@types/qs': specifier: ^6.9.18 version: 6.9.18 @@ -5871,7 +5865,8 @@ snapshots: pg-cloudflare@1.1.1: optional: true - pg-connection-string@2.7.0: {} + pg-connection-string@2.7.0: + optional: true pg-int8@1.0.1: {} @@ -5880,6 +5875,7 @@ snapshots: pg-pool@3.8.0(pg@8.14.1): dependencies: pg: 8.14.1 + optional: true pg-protocol@1.8.0: {} @@ -5910,10 +5906,12 @@ 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: {} @@ -6175,7 +6173,8 @@ snapshots: wicked-good-xpath: 1.3.0 optional: true - split2@4.2.0: {} + split2@4.2.0: + optional: true sprintf-js@1.0.3: {}