mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
replace kysely_deno_postgres with kysely-postgres-js
This commit is contained in:
parent
bdd3b2224e
commit
ae140933f5
3 changed files with 24 additions and 28 deletions
|
|
@ -50,7 +50,8 @@
|
|||
"iso-639-1": "npm:iso-639-1@2.1.15",
|
||||
"isomorphic-dompurify": "npm:isomorphic-dompurify@^2.11.0",
|
||||
"kysely": "npm:kysely@^0.27.3",
|
||||
"kysely_deno_postgres": "https://gitlab.com/soapbox-pub/kysely-deno-postgres/-/raw/b4725e74ad6ca359ba0e370b55dbb8bb845a8a83/mod.ts",
|
||||
"kysely-postgres-js": "npm:kysely-postgres-js@2.0.0",
|
||||
"postgres": "npm:postgres@3.4.4",
|
||||
"light-bolt11-decoder": "npm:light-bolt11-decoder",
|
||||
"linkify-plugin-hashtag": "npm:linkify-plugin-hashtag@^4.1.1",
|
||||
"linkify-string": "npm:linkify-string@^4.1.1",
|
||||
|
|
@ -59,7 +60,6 @@
|
|||
"nostr-relaypool": "npm:nostr-relaypool2@0.6.34",
|
||||
"nostr-tools": "npm:nostr-tools@2.5.1",
|
||||
"nostr-wasm": "npm:nostr-wasm@^0.1.0",
|
||||
"postgres": "https://deno.land/x/postgres@v0.19.0/mod.ts",
|
||||
"prom-client": "npm:prom-client@^15.1.2",
|
||||
"question-deno": "https://raw.githubusercontent.com/ocpu/question-deno/10022b8e52555335aa510adb08b0a300df3cf904/mod.ts",
|
||||
"tldts": "npm:tldts@^6.0.14",
|
||||
|
|
|
|||
15
deno.lock
generated
15
deno.lock
generated
|
|
@ -47,6 +47,7 @@
|
|||
"npm:hono-rate-limiter@^0.3.0": "npm:hono-rate-limiter@0.3.0_hono@4.2.5",
|
||||
"npm:iso-639-1@2.1.15": "npm:iso-639-1@2.1.15",
|
||||
"npm:isomorphic-dompurify@^2.11.0": "npm:isomorphic-dompurify@2.11.0",
|
||||
"npm:kysely-postgres-js@2.0.0": "npm:kysely-postgres-js@2.0.0_kysely@0.27.3_postgres@3.4.4",
|
||||
"npm:kysely@0.27.3": "npm:kysely@0.27.3",
|
||||
"npm:kysely@^0.27.2": "npm:kysely@0.27.3",
|
||||
"npm:kysely@^0.27.3": "npm:kysely@0.27.3",
|
||||
|
|
@ -62,6 +63,7 @@
|
|||
"npm:nostr-tools@^2.5.0": "npm:nostr-tools@2.5.1",
|
||||
"npm:nostr-tools@^2.7.0": "npm:nostr-tools@2.7.0",
|
||||
"npm:nostr-wasm@^0.1.0": "npm:nostr-wasm@0.1.0",
|
||||
"npm:postgres@3.4.4": "npm:postgres@3.4.4",
|
||||
"npm:prom-client@^15.1.2": "npm:prom-client@15.1.2",
|
||||
"npm:tldts@^6.0.14": "npm:tldts@6.1.18",
|
||||
"npm:type-fest@^4.3.0": "npm:type-fest@4.18.2",
|
||||
|
|
@ -664,6 +666,13 @@
|
|||
"xml-name-validator": "xml-name-validator@5.0.0"
|
||||
}
|
||||
},
|
||||
"kysely-postgres-js@2.0.0_kysely@0.27.3_postgres@3.4.4": {
|
||||
"integrity": "sha512-R1tWx6/x3tSatWvsmbHJxpBZYhNNxcnMw52QzZaHKg7ZOWtHib4iZyEaw4gb2hNKVctWQ3jfMxZT/ZaEMK6kBQ==",
|
||||
"dependencies": {
|
||||
"kysely": "kysely@0.27.3",
|
||||
"postgres": "postgres@3.4.4"
|
||||
}
|
||||
},
|
||||
"kysely@0.27.3": {
|
||||
"integrity": "sha512-lG03Ru+XyOJFsjH3OMY6R/9U38IjDPfnOfDgO3ynhbDr+Dz8fak+X6L62vqu3iybQnj+lG84OttBuU9KY3L9kA==",
|
||||
"dependencies": {}
|
||||
|
|
@ -868,6 +877,10 @@
|
|||
"integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==",
|
||||
"dependencies": {}
|
||||
},
|
||||
"postgres@3.4.4": {
|
||||
"integrity": "sha512-IbyN+9KslkqcXa8AO9fxpk97PA4pzewvpi2B3Dwy9u4zpV32QicaEdgmF3eSQUzdRk7ttDHQejNgAEr4XoeH4A==",
|
||||
"dependencies": {}
|
||||
},
|
||||
"prom-client@15.1.2": {
|
||||
"integrity": "sha512-on3h1iXb04QFLLThrmVYg1SChBQ9N1c+nKAjebBjokBqipddH3uxmOUcEkTnzmJ8Jh/5TSUnUqS40i2QB2dJHQ==",
|
||||
"dependencies": {
|
||||
|
|
@ -1442,6 +1455,7 @@
|
|||
"npm:hono-rate-limiter@^0.3.0",
|
||||
"npm:iso-639-1@2.1.15",
|
||||
"npm:isomorphic-dompurify@^2.11.0",
|
||||
"npm:kysely-postgres-js@2.0.0",
|
||||
"npm:kysely@^0.27.3",
|
||||
"npm:light-bolt11-decoder",
|
||||
"npm:linkify-plugin-hashtag@^4.1.1",
|
||||
|
|
@ -1451,6 +1465,7 @@
|
|||
"npm:nostr-relaypool2@0.6.34",
|
||||
"npm:nostr-tools@2.5.1",
|
||||
"npm:nostr-wasm@^0.1.0",
|
||||
"npm:postgres@3.4.4",
|
||||
"npm:prom-client@^15.1.2",
|
||||
"npm:tldts@^6.0.14",
|
||||
"npm:tseep@^1.2.1",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler } from 'kysely';
|
||||
import { PostgreSQLDriver } from 'kysely_deno_postgres';
|
||||
import { Pool } from 'postgres';
|
||||
import { Kysely } from 'kysely';
|
||||
import { PostgresJSDialect } from "kysely-postgres-js";
|
||||
import postgres from 'postgres';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { DittoTables } from '@/db/DittoTables.ts';
|
||||
|
|
@ -8,34 +8,15 @@ import { KyselyLogger } from '@/db/KyselyLogger.ts';
|
|||
|
||||
export class DittoPostgres {
|
||||
static db: Kysely<DittoTables> | undefined;
|
||||
static pool: Pool | undefined;
|
||||
|
||||
static getPool(): Pool {
|
||||
if (!this.pool) {
|
||||
this.pool = new Pool(Conf.databaseUrl, Conf.pg.poolSize);
|
||||
}
|
||||
return this.pool;
|
||||
}
|
||||
|
||||
// deno-lint-ignore require-await
|
||||
static async getInstance(): Promise<Kysely<DittoTables>> {
|
||||
if (!this.db) {
|
||||
this.db = new Kysely({
|
||||
dialect: {
|
||||
createAdapter() {
|
||||
return new PostgresAdapter();
|
||||
},
|
||||
createDriver() {
|
||||
return new PostgreSQLDriver(DittoPostgres.getPool());
|
||||
},
|
||||
createIntrospector(db: Kysely<unknown>) {
|
||||
return new PostgresIntrospector(db);
|
||||
},
|
||||
createQueryCompiler() {
|
||||
return new PostgresQueryCompiler();
|
||||
},
|
||||
},
|
||||
log: KyselyLogger,
|
||||
dialect: new PostgresJSDialect({
|
||||
postgres: postgres(Conf.databaseUrl)
|
||||
}),
|
||||
log: KyselyLogger
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue