From 58ed1b111f09083728bbc340ff1bf5ab55834db3 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 15:55:56 -0500 Subject: [PATCH 01/14] Comlink alias --- deno.json | 1 + deno.lock | 7 +++++++ src/deps.ts | 1 - src/workers/fetch.ts | 2 +- src/workers/fetch.worker.ts | 4 +++- src/workers/handlers/abortsignal.ts | 2 +- src/workers/sqlite.ts | 5 ++--- src/workers/sqlite.worker.ts | 3 ++- src/workers/trends.ts | 2 +- src/workers/trends.worker.ts | 4 +++- src/workers/verify.ts | 2 +- src/workers/verify.worker.ts | 2 +- 12 files changed, 23 insertions(+), 12 deletions(-) diff --git a/deno.json b/deno.json index 3eae632..aa6c475 100644 --- a/deno.json +++ b/deno.json @@ -24,6 +24,7 @@ "@std/json": "jsr:@std/json@^0.223.0", "@std/media-types": "jsr:@std/media-types@^0.224.0", "@std/streams": "jsr:@std/streams@^0.223.0", + "comlink": "npm:comlink@^4.4.1", "hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "kysely": "npm:kysely@^0.27.3", diff --git a/deno.lock b/deno.lock index f984b36..2258654 100644 --- a/deno.lock +++ b/deno.lock @@ -1313,15 +1313,18 @@ "https://deno.land/x/hono@v3.10.1/adapter/deno/serve-static.ts": "ba10cf6aaf39da942b0d49c3b9877ddba69d41d414c6551d890beb1085f58eea", "https://deno.land/x/hono@v3.10.1/client/client.ts": "ff340f58041203879972dd368b011ed130c66914f789826610869a90603406bf", "https://deno.land/x/hono@v3.10.1/client/index.ts": "3ff4cf246f3543f827a85a2c84d66a025ac350ee927613629bda47e854bfb7ba", + "https://deno.land/x/hono@v3.10.1/client/types.ts": "52c66cbe74540e1811259a48c30622ac915666196eb978092d166435cbc15213", "https://deno.land/x/hono@v3.10.1/client/utils.ts": "053273c002963b549d38268a1b423ac8ca211a8028bdab1ed0b781a62aa5e661", "https://deno.land/x/hono@v3.10.1/compose.ts": "e8ab4b345aa367f2dd65f221c9fe829dd885326a613f4215b654f93a4066bb5c", "https://deno.land/x/hono@v3.10.1/context.ts": "261cc8b8b1e8f04b98beab1cca6692f317b7dc6d2b75b4f84c982e54cf1db730", + "https://deno.land/x/hono@v3.10.1/helper/adapter/index.ts": "eea9b4caedbfa3a3b4a020bf46c88c0171a00008cd6c10708cd85a3e39d86e62", "https://deno.land/x/hono@v3.10.1/helper/cookie/index.ts": "55ccd20bbd8d9a8bb2ecd998e90845c1d306c19027f54b3d1b89a5be35968b80", "https://deno.land/x/hono@v3.10.1/helper/html/index.ts": "aba19e8d29f217c7fffa5719cf606c4e259b540d51296e82bbea3c992e2ecbc6", "https://deno.land/x/hono@v3.10.1/hono-base.ts": "cc55e0a4c63a7bdf44df3e804ea4737d5399eeb6606b45d102f8e48c3ff1e925", "https://deno.land/x/hono@v3.10.1/hono.ts": "2cc4c292e541463a4d6f83edbcea58048d203e9564ae62ec430a3d466b49a865", "https://deno.land/x/hono@v3.10.1/http-exception.ts": "6071df078b5f76d279684d52fe82a590f447a64ffe1b75eb5064d0c8a8d2d676", "https://deno.land/x/hono@v3.10.1/jsx/index.ts": "019512d3a9b3897b879e87fa5fb179cd34f3d326f8ff8b93379c2bb707ec168a", + "https://deno.land/x/hono@v3.10.1/jsx/intrinsic-elements.ts": "03250beb610bda1c72017bc0912c2505ff764b7a8d869e7e4add40eb4cfec096", "https://deno.land/x/hono@v3.10.1/jsx/streaming.ts": "5d03b4d02eaa396c8f0f33c3f6e8c7ed3afb7598283c2d4a7ddea0ada8c212a7", "https://deno.land/x/hono@v3.10.1/middleware.ts": "57b2047c4b9d775a052a9c44a3b805802c1d1cb477ab9c4bb6185d27382d1b96", "https://deno.land/x/hono@v3.10.1/middleware/basic-auth/index.ts": "5505288ccf9364f56f7be2dfac841543b72e20656e54ac646a1a73a0aa853261", @@ -1353,6 +1356,7 @@ "https://deno.land/x/hono@v3.10.1/router/trie-router/index.ts": "3eb75e7f71ba81801631b30de6b1f5cefb2c7239c03797e2b2cbab5085911b41", "https://deno.land/x/hono@v3.10.1/router/trie-router/node.ts": "3af15fa9c9994a8664a2b7a7c11233504b5bb9d4fcf7bb34cf30d7199052c39f", "https://deno.land/x/hono@v3.10.1/router/trie-router/router.ts": "54ced78d35676302c8fcdda4204f7bdf5a7cc907fbf9967c75674b1e394f830d", + "https://deno.land/x/hono@v3.10.1/types.ts": "edc414a92383f9deb82f5f7a09e95bcf76f6100c23457c27d041986768f5345c", "https://deno.land/x/hono@v3.10.1/utils/body.ts": "7a16a6656331a96bcae57642f8d5e3912bd361cbbcc2c0d2157ecc3f218f7a92", "https://deno.land/x/hono@v3.10.1/utils/buffer.ts": "9066a973e64498cb262c7e932f47eed525a51677b17f90893862b7279dc0773e", "https://deno.land/x/hono@v3.10.1/utils/cookie.ts": "19920ba6756944aae1ad8585c3ddeaa9df479733f59d05359db096f7361e5e4b", @@ -1360,11 +1364,13 @@ "https://deno.land/x/hono@v3.10.1/utils/encode.ts": "3b7c7d736123b5073542b34321700d4dbf5ff129c138f434bb2144a4d425ee89", "https://deno.land/x/hono@v3.10.1/utils/filepath.ts": "18461b055a914d6da85077f453051b516281bb17cf64fa74bf5ef604dc9d2861", "https://deno.land/x/hono@v3.10.1/utils/html.ts": "01c1520a4256f899da1954357cf63ae11c348eda141a505f72d7090cf5481aba", + "https://deno.land/x/hono@v3.10.1/utils/http-status.ts": "e0c4343ea7717c314dc600131e16b636c29d61cfdaf9df93b267258d1729d1a0", "https://deno.land/x/hono@v3.10.1/utils/jwt/index.ts": "5e4b82a42eb3603351dfce726cd781ca41cb57437395409d227131aec348d2d5", "https://deno.land/x/hono@v3.10.1/utils/jwt/jwt.ts": "02ff7bbf1298ffcc7a40266842f8eac44b6c136453e32d4441e24d0cbfba3a95", "https://deno.land/x/hono@v3.10.1/utils/jwt/types.ts": "58ddf908f76ba18d9c62ddfc2d1e40cc2e306bf987409a6169287efa81ce2546", "https://deno.land/x/hono@v3.10.1/utils/mime.ts": "0105d2b5e8e91f07acc70f5d06b388313995d62af23c802fcfba251f5a744d95", "https://deno.land/x/hono@v3.10.1/utils/stream.ts": "1789dcc73c5b0ede28f83d7d34e47ae432c20e680907cb3275a9c9187f293983", + "https://deno.land/x/hono@v3.10.1/utils/types.ts": "ddff055e6d35066232efdfbd42c8954e855c04279c27dcd735d929b6b4f319b3", "https://deno.land/x/hono@v3.10.1/utils/url.ts": "5fc3307ef3cb2e6f34ec2a03e3d7f2126c6a9f5f0eab677222df3f0e40bd7567", "https://deno.land/x/hono@v3.10.1/validator/index.ts": "6c986e8b91dcf857ecc8164a506ae8eea8665792a4ff7215471df669c632ae7c", "https://deno.land/x/hono@v3.10.1/validator/validator.ts": "afa5e52495e0996fbba61996736fab5c486590d72d376f809e9f9ff4e0c463e9", @@ -1496,6 +1502,7 @@ "jsr:@std/json@^0.223.0", "jsr:@std/media-types@^0.224.0", "jsr:@std/streams@^0.223.0", + "npm:comlink@^4.4.1", "npm:kysely@^0.27.3", "npm:nostr-tools@^2.5.1", "npm:nostr-wasm@^0.1.0", diff --git a/src/deps.ts b/src/deps.ts index 2c84d9e..2111f0f 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -36,7 +36,6 @@ export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; export { default as uuid62 } from 'npm:uuid62@^1.0.2'; export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; -export * as Comlink from 'npm:comlink@^4.4.1'; export { EventEmitter } from 'npm:tseep@^1.1.3'; export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; export { default as Debug } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/debug.ts'; diff --git a/src/workers/fetch.ts b/src/workers/fetch.ts index 510d806..f0bece5 100644 --- a/src/workers/fetch.ts +++ b/src/workers/fetch.ts @@ -1,4 +1,4 @@ -import { Comlink } from '@/deps.ts'; +import * as Comlink from 'comlink'; import './handlers/abortsignal.ts'; diff --git a/src/workers/fetch.worker.ts b/src/workers/fetch.worker.ts index 8e79465..c3b4c72 100644 --- a/src/workers/fetch.worker.ts +++ b/src/workers/fetch.worker.ts @@ -1,4 +1,6 @@ -import { Comlink, Debug } from '@/deps.ts'; +import * as Comlink from 'comlink'; + +import { Debug } from '@/deps.ts'; import './handlers/abortsignal.ts'; diff --git a/src/workers/handlers/abortsignal.ts b/src/workers/handlers/abortsignal.ts index c4c6a3e..14cf9f4 100644 --- a/src/workers/handlers/abortsignal.ts +++ b/src/workers/handlers/abortsignal.ts @@ -1,4 +1,4 @@ -import { Comlink } from '@/deps.ts'; +import * as Comlink from 'comlink'; const signalFinalizers = new FinalizationRegistry((port: MessagePort) => { port.postMessage(null); diff --git a/src/workers/sqlite.ts b/src/workers/sqlite.ts index 1d29d4a..c6f2d2e 100644 --- a/src/workers/sqlite.ts +++ b/src/workers/sqlite.ts @@ -1,6 +1,5 @@ -import type { CompiledQuery, QueryResult } from 'kysely'; - -import { Comlink } from '@/deps.ts'; +import * as Comlink from 'comlink'; +import { CompiledQuery, QueryResult } from 'kysely'; import type { SqliteWorker as _SqliteWorker } from './sqlite.worker.ts'; diff --git a/src/workers/sqlite.worker.ts b/src/workers/sqlite.worker.ts index 4739638..753e7ae 100644 --- a/src/workers/sqlite.worker.ts +++ b/src/workers/sqlite.worker.ts @@ -1,8 +1,9 @@ /// import { ScopedPerformance } from 'https://deno.land/x/scoped_performance@v2.0.0/mod.ts'; +import * as Comlink from 'comlink'; import { CompiledQuery, QueryResult } from 'kysely'; -import { Comlink, DenoSqlite3, Stickynotes } from '@/deps.ts'; +import { DenoSqlite3, Stickynotes } from '@/deps.ts'; import '@/sentry.ts'; let db: DenoSqlite3 | undefined; diff --git a/src/workers/trends.ts b/src/workers/trends.ts index b455283..31db381 100644 --- a/src/workers/trends.ts +++ b/src/workers/trends.ts @@ -1,4 +1,4 @@ -import { Comlink } from '@/deps.ts'; +import * as Comlink from 'comlink'; import type { TrendsWorker as _TrendsWorker } from '@/workers/trends.worker.ts'; diff --git a/src/workers/trends.worker.ts b/src/workers/trends.worker.ts index df06fbb..819883f 100644 --- a/src/workers/trends.worker.ts +++ b/src/workers/trends.worker.ts @@ -1,4 +1,6 @@ -import { Comlink, Sqlite } from '@/deps.ts'; +import * as Comlink from 'comlink'; + +import { Sqlite } from '@/deps.ts'; import { hashtagSchema } from '@/schema.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; import { generateDateRange, Time } from '@/utils/time.ts'; diff --git a/src/workers/verify.ts b/src/workers/verify.ts index 0dde872..15ad783 100644 --- a/src/workers/verify.ts +++ b/src/workers/verify.ts @@ -1,5 +1,5 @@ import { NostrEvent } from '@nostrify/nostrify'; -import { Comlink } from '@/deps.ts'; +import * as Comlink from 'comlink'; import type { VerifyWorker } from './verify.worker.ts'; diff --git a/src/workers/verify.worker.ts b/src/workers/verify.worker.ts index d72387a..e218474 100644 --- a/src/workers/verify.worker.ts +++ b/src/workers/verify.worker.ts @@ -1,7 +1,7 @@ import { NostrEvent } from '@nostrify/nostrify'; +import * as Comlink from 'comlink'; import { VerifiedEvent, verifyEvent } from 'nostr-tools'; -import { Comlink } from '@/deps.ts'; import '@/nostr-wasm.ts'; export const VerifyWorker = { From 9d0be2de0d142579014bb38c4440b9bffa2a3d40 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 15:57:28 -0500 Subject: [PATCH 02/14] nostr-relaypool alias --- deno.json | 1 + deno.lock | 1 + src/deps.ts | 1 - src/pool.ts | 3 ++- src/storages/pool-store.ts | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index aa6c475..e3cd02f 100644 --- a/deno.json +++ b/deno.json @@ -29,6 +29,7 @@ "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "kysely": "npm:kysely@^0.27.3", "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts", + "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", "nostr-wasm": "npm:nostr-wasm@^0.1.0", "zod": "npm:zod@^3.23.4", diff --git a/deno.lock b/deno.lock index 2258654..508e7fb 100644 --- a/deno.lock +++ b/deno.lock @@ -1504,6 +1504,7 @@ "jsr:@std/streams@^0.223.0", "npm:comlink@^4.4.1", "npm:kysely@^0.27.3", + "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", "npm:nostr-wasm@^0.1.0", "npm:zod@^3.23.4" diff --git a/src/deps.ts b/src/deps.ts index 2111f0f..da98d64 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,5 +1,4 @@ import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts'; -export { RelayPoolWorker } from 'npm:nostr-relaypool2@0.6.34'; export { parseFormData } from 'npm:formdata-helper@^0.3.0'; // @deno-types="npm:@types/lodash@4.14.194" export { default as lodash } from 'https://esm.sh/lodash@4.17.21'; diff --git a/src/pool.ts b/src/pool.ts index 06c251e..48d5e1f 100644 --- a/src/pool.ts +++ b/src/pool.ts @@ -1,5 +1,6 @@ +import { RelayPoolWorker } from 'nostr-relaypool'; + import { getActiveRelays } from '@/db/relays.ts'; -import { RelayPoolWorker } from '@/deps.ts'; const activeRelays = await getActiveRelays(); diff --git a/src/storages/pool-store.ts b/src/storages/pool-store.ts index 93ca24e..a8bd09a 100644 --- a/src/storages/pool-store.ts +++ b/src/storages/pool-store.ts @@ -1,7 +1,8 @@ import { NostrEvent, NostrFilter, NSet, NStore } from '@nostrify/nostrify'; +import { RelayPoolWorker } from 'nostr-relaypool'; import { matchFilters } from 'nostr-tools'; -import { Debug, type RelayPoolWorker } from '@/deps.ts'; +import { Debug } from '@/deps.ts'; import { normalizeFilters } from '@/filter.ts'; import { purifyEvent } from '@/storages/hydrate.ts'; import { abortError } from '@/utils/abort.ts'; From 3513206de1670b59369504a5b36443ebdf0eea18 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:14:50 -0500 Subject: [PATCH 03/14] stickynotes alias --- deno.json | 1 + deno.lock | 5 +++++ src/app.ts | 2 +- src/controllers/api/streaming.ts | 2 +- src/db/users.ts | 3 ++- src/deps.ts | 2 -- src/firehose.ts | 3 ++- src/middleware/cache.ts | 3 ++- src/pipeline.ts | 2 +- src/queries.ts | 3 ++- src/stats.ts | 2 +- src/storages/events-db.ts | 2 +- src/storages/optimizer.ts | 3 ++- src/storages/pool-store.ts | 2 +- src/storages/reqmeister.ts | 4 +++- src/storages/search-store.ts | 3 ++- src/utils/api.ts | 3 ++- src/utils/lnurl.ts | 3 ++- src/utils/nip05.ts | 2 +- src/utils/unfurl.ts | 4 +++- src/workers/fetch.worker.ts | 3 +-- src/workers/sqlite.worker.ts | 3 ++- 22 files changed, 38 insertions(+), 22 deletions(-) diff --git a/deno.json b/deno.json index e3cd02f..3b6c042 100644 --- a/deno.json +++ b/deno.json @@ -18,6 +18,7 @@ "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", + "@soapbox/stickynotes": "jsr:@soapbox/stickynotes@^0.4.0", "@std/cli": "jsr:@std/cli@^0.223.0", "@std/crypto": "jsr:@std/crypto@^0.224.0", "@std/encoding": "jsr:@std/encoding@^0.224.0", diff --git a/deno.lock b/deno.lock index 508e7fb..9c302b1 100644 --- a/deno.lock +++ b/deno.lock @@ -4,6 +4,7 @@ "specifiers": { "jsr:@nostrify/nostrify@^0.15.0": "jsr:@nostrify/nostrify@0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2": "jsr:@soapbox/kysely-deno-sqlite@2.0.2", + "jsr:@soapbox/stickynotes@^0.4.0": "jsr:@soapbox/stickynotes@0.4.0", "jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0", "jsr:@std/crypto@^0.224.0": "jsr:@std/crypto@0.224.0", "jsr:@std/encoding@^0.224.0": "jsr:@std/encoding@0.224.0", @@ -68,6 +69,9 @@ "npm:kysely@^0.27.2" ] }, + "@soapbox/stickynotes@0.4.0": { + "integrity": "60bfe61ab3d7e04bf708273b1e2d391a59534bdf29e54160e98d7afd328ca1ec" + }, "@std/assert@0.224.0": { "integrity": "8643233ec7aec38a940a8264a6e3eed9bfa44e7a71cc6b3c8874213ff401967f" }, @@ -1496,6 +1500,7 @@ "dependencies": [ "jsr:@nostrify/nostrify@^0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", + "jsr:@soapbox/stickynotes@^0.4.0", "jsr:@std/cli@^0.223.0", "jsr:@std/crypto@^0.224.0", "jsr:@std/encoding@^0.224.0", diff --git a/src/app.ts b/src/app.ts index 370abc5..7e91a01 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,9 +1,9 @@ import { NostrEvent, NStore } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { type Context, Env as HonoEnv, type Handler, Hono, Input as HonoInput, type MiddlewareHandler } from 'hono'; import { cors, logger, serveStatic } from 'hono/middleware'; import { type User } from '@/db/users.ts'; -import { Debug } from '@/deps.ts'; import '@/firehose.ts'; import { Time } from '@/utils.ts'; diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 4bbc627..965855c 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -1,9 +1,9 @@ import { NostrFilter } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { z } from 'zod'; import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { Debug } from '@/deps.ts'; import { getFeedPubkeys } from '@/queries.ts'; import { bech32ToPubkey } from '@/utils.ts'; import { renderReblog, renderStatus } from '@/views/mastodon/statuses.ts'; diff --git a/src/db/users.ts b/src/db/users.ts index 841e981..c7659e4 100644 --- a/src/db/users.ts +++ b/src/db/users.ts @@ -1,6 +1,7 @@ import { NostrFilter } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; + import { Conf } from '@/config.ts'; -import { Debug } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { Storages } from '@/storages.ts'; diff --git a/src/deps.ts b/src/deps.ts index da98d64..2878bc6 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -37,7 +37,5 @@ export { default as uuid62 } from 'npm:uuid62@^1.0.2'; export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; export { EventEmitter } from 'npm:tseep@^1.1.3'; export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; -export { default as Debug } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/debug.ts'; -export { Stickynotes } from 'https://gitlab.com/soapbox-pub/stickynotes/-/raw/v0.3.0/mod.ts'; export type * as TypeFest from 'npm:type-fest@^4.3.0'; diff --git a/src/firehose.ts b/src/firehose.ts index 98cb4db..d7aaab3 100644 --- a/src/firehose.ts +++ b/src/firehose.ts @@ -1,5 +1,6 @@ import { NostrEvent } from '@nostrify/nostrify'; -import { Debug } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + import { activeRelays, pool } from '@/pool.ts'; import { nostrNow } from '@/utils.ts'; diff --git a/src/middleware/cache.ts b/src/middleware/cache.ts index fe28c5f..181623f 100644 --- a/src/middleware/cache.ts +++ b/src/middleware/cache.ts @@ -1,5 +1,6 @@ +import Debug from '@soapbox/stickynotes/debug'; import { type MiddlewareHandler } from 'hono'; -import { Debug } from '@/deps.ts'; + import ExpiringCache from '@/utils/expiring-cache.ts'; const debug = Debug('ditto:middleware:cache'); diff --git a/src/pipeline.ts b/src/pipeline.ts index 5fa9f23..f91626d 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -1,12 +1,12 @@ import { NostrEvent, NSchema as n } from '@nostrify/nostrify'; import { LNURL } from '@nostrify/nostrify/ln'; +import Debug from '@soapbox/stickynotes/debug'; import { sql } from 'kysely'; import { Conf } from '@/config.ts'; import { db } from '@/db.ts'; import { addRelays } from '@/db/relays.ts'; import { deleteAttachedMedia } from '@/db/unattached-media.ts'; -import { Debug } from '@/deps.ts'; import { DittoEvent } from '@/interfaces/DittoEvent.ts'; import { isEphemeralKind } from '@/kinds.ts'; import { DVM } from '@/pipeline/DVM.ts'; diff --git a/src/queries.ts b/src/queries.ts index e4fdc21..5626c45 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -1,7 +1,8 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; + import { Conf } from '@/config.ts'; import { Storages } from '@/storages.ts'; -import { Debug } from '@/deps.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { type DittoRelation } from '@/interfaces/DittoFilter.ts'; import { findReplyTag, getTagSet } from '@/tags.ts'; diff --git a/src/stats.ts b/src/stats.ts index e75b57c..2bb3e59 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -1,9 +1,9 @@ import { NostrEvent } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { InsertQueryBuilder } from 'kysely'; import { db } from '@/db.ts'; import { DittoTables } from '@/db/DittoTables.ts'; -import { Debug } from '@/deps.ts'; import { Storages } from '@/storages.ts'; import { findReplyTag } from '@/tags.ts'; diff --git a/src/storages/events-db.ts b/src/storages/events-db.ts index 22f15e1..74bcb01 100644 --- a/src/storages/events-db.ts +++ b/src/storages/events-db.ts @@ -1,9 +1,9 @@ import { NIP50, NostrEvent, NostrFilter, NStore } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { Kysely, type SelectQueryBuilder } from 'kysely'; import { Conf } from '@/config.ts'; import { DittoTables } from '@/db/DittoTables.ts'; -import { Debug } from '@/deps.ts'; import { normalizeFilters } from '@/filter.ts'; import { DittoEvent } from '@/interfaces/DittoEvent.ts'; import { isDittoInternalKind, isParameterizedReplaceableKind, isReplaceableKind } from '@/kinds.ts'; diff --git a/src/storages/optimizer.ts b/src/storages/optimizer.ts index 518fc15..7b4153e 100644 --- a/src/storages/optimizer.ts +++ b/src/storages/optimizer.ts @@ -1,5 +1,6 @@ import { NostrFilter, NSet, NStore } from '@nostrify/nostrify'; -import { Debug } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + import { normalizeFilters } from '@/filter.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { abortError } from '@/utils/abort.ts'; diff --git a/src/storages/pool-store.ts b/src/storages/pool-store.ts index a8bd09a..953720b 100644 --- a/src/storages/pool-store.ts +++ b/src/storages/pool-store.ts @@ -1,8 +1,8 @@ import { NostrEvent, NostrFilter, NSet, NStore } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { RelayPoolWorker } from 'nostr-relaypool'; import { matchFilters } from 'nostr-tools'; -import { Debug } from '@/deps.ts'; import { normalizeFilters } from '@/filter.ts'; import { purifyEvent } from '@/storages/hydrate.ts'; import { abortError } from '@/utils/abort.ts'; diff --git a/src/storages/reqmeister.ts b/src/storages/reqmeister.ts index 6be5a56..a385ec9 100644 --- a/src/storages/reqmeister.ts +++ b/src/storages/reqmeister.ts @@ -1,5 +1,7 @@ import { NostrEvent, NostrFilter, NStore } from '@nostrify/nostrify'; -import { Debug, EventEmitter } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + +import { EventEmitter } from '@/deps.ts'; import { eventToMicroFilter, getFilterId, isMicrofilter, type MicroFilter } from '@/filter.ts'; import { Time } from '@/utils/time.ts'; import { abortError } from '@/utils/abort.ts'; diff --git a/src/storages/search-store.ts b/src/storages/search-store.ts index 6150896..be6e2b4 100644 --- a/src/storages/search-store.ts +++ b/src/storages/search-store.ts @@ -1,5 +1,6 @@ import { NostrEvent, NostrFilter, NRelay1, NStore } from '@nostrify/nostrify'; -import { Debug } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + import { normalizeFilters } from '@/filter.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { hydrateEvents } from '@/storages/hydrate.ts'; diff --git a/src/utils/api.ts b/src/utils/api.ts index 7b090ee..ee0ede2 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,11 +1,12 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { type Context, HTTPException } from 'hono'; import { EventTemplate } from 'nostr-tools'; import { z } from 'zod'; import { type AppContext } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { Debug, parseFormData, type TypeFest } from '@/deps.ts'; +import { parseFormData, type TypeFest } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { APISigner } from '@/signers/APISigner.ts'; diff --git a/src/utils/lnurl.ts b/src/utils/lnurl.ts index a84d20b..ea5ce8a 100644 --- a/src/utils/lnurl.ts +++ b/src/utils/lnurl.ts @@ -1,5 +1,6 @@ import { LNURL, LNURLDetails } from '@nostrify/nostrify/ln'; -import { Debug } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + import { SimpleLRU } from '@/utils/SimpleLRU.ts'; import { Time } from '@/utils/time.ts'; import { fetchWorker } from '@/workers/fetch.ts'; diff --git a/src/utils/nip05.ts b/src/utils/nip05.ts index bcef61f..0b4c6e3 100644 --- a/src/utils/nip05.ts +++ b/src/utils/nip05.ts @@ -1,8 +1,8 @@ import { NIP05 } from '@nostrify/nostrify'; +import Debug from '@soapbox/stickynotes/debug'; import { nip19 } from 'nostr-tools'; import { Conf } from '@/config.ts'; -import { Debug } from '@/deps.ts'; import { SimpleLRU } from '@/utils/SimpleLRU.ts'; import { Time } from '@/utils/time.ts'; import { Storages } from '@/storages.ts'; diff --git a/src/utils/unfurl.ts b/src/utils/unfurl.ts index da11e84..bde5561 100644 --- a/src/utils/unfurl.ts +++ b/src/utils/unfurl.ts @@ -1,4 +1,6 @@ -import { Debug, sanitizeHtml, TTLCache, unfurl } from '@/deps.ts'; +import Debug from '@soapbox/stickynotes/debug'; + +import { sanitizeHtml, TTLCache, unfurl } from '@/deps.ts'; import { Time } from '@/utils/time.ts'; import { fetchWorker } from '@/workers/fetch.ts'; diff --git a/src/workers/fetch.worker.ts b/src/workers/fetch.worker.ts index c3b4c72..d44e043 100644 --- a/src/workers/fetch.worker.ts +++ b/src/workers/fetch.worker.ts @@ -1,7 +1,6 @@ +import Debug from '@soapbox/stickynotes/debug'; import * as Comlink from 'comlink'; -import { Debug } from '@/deps.ts'; - import './handlers/abortsignal.ts'; const debug = Debug('ditto:fetch.worker'); diff --git a/src/workers/sqlite.worker.ts b/src/workers/sqlite.worker.ts index 753e7ae..df9d6f0 100644 --- a/src/workers/sqlite.worker.ts +++ b/src/workers/sqlite.worker.ts @@ -1,9 +1,10 @@ /// import { ScopedPerformance } from 'https://deno.land/x/scoped_performance@v2.0.0/mod.ts'; +import { Stickynotes } from '@soapbox/stickynotes'; import * as Comlink from 'comlink'; import { CompiledQuery, QueryResult } from 'kysely'; -import { DenoSqlite3, Stickynotes } from '@/deps.ts'; +import { DenoSqlite3 } from '@/deps.ts'; import '@/sentry.ts'; let db: DenoSqlite3 | undefined; From 973791cde1755eeca3e5a0599e99c5d2e9a42e06 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:16:19 -0500 Subject: [PATCH 04/14] type-fest alias --- deno.json | 1 + deno.lock | 1 + src/deps.ts | 2 -- src/utils/api.ts | 3 ++- src/views/mastodon/attachments.ts | 3 ++- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/deno.json b/deno.json index 3b6c042..0bc5d0b 100644 --- a/deno.json +++ b/deno.json @@ -33,6 +33,7 @@ "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", "nostr-wasm": "npm:nostr-wasm@^0.1.0", + "type-fest": "npm:type-fest@^4.3.0", "zod": "npm:zod@^3.23.4", "~/fixtures/": "./fixtures/" }, diff --git a/deno.lock b/deno.lock index 9c302b1..eb53807 100644 --- a/deno.lock +++ b/deno.lock @@ -1512,6 +1512,7 @@ "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", "npm:nostr-wasm@^0.1.0", + "npm:type-fest@^4.3.0", "npm:zod@^3.23.4" ] } diff --git a/src/deps.ts b/src/deps.ts index 2878bc6..78e90d0 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -37,5 +37,3 @@ export { default as uuid62 } from 'npm:uuid62@^1.0.2'; export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; export { EventEmitter } from 'npm:tseep@^1.1.3'; export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; - -export type * as TypeFest from 'npm:type-fest@^4.3.0'; diff --git a/src/utils/api.ts b/src/utils/api.ts index ee0ede2..85d5783 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -2,11 +2,12 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import Debug from '@soapbox/stickynotes/debug'; import { type Context, HTTPException } from 'hono'; import { EventTemplate } from 'nostr-tools'; +import * as TypeFest from 'type-fest'; import { z } from 'zod'; import { type AppContext } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { parseFormData, type TypeFest } from '@/deps.ts'; +import { parseFormData } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { APISigner } from '@/signers/APISigner.ts'; diff --git a/src/views/mastodon/attachments.ts b/src/views/mastodon/attachments.ts index 38ddb37..3ea989e 100644 --- a/src/views/mastodon/attachments.ts +++ b/src/views/mastodon/attachments.ts @@ -1,5 +1,6 @@ +import * as TypeFest from 'type-fest'; + import { UnattachedMedia } from '@/db/unattached-media.ts'; -import { type TypeFest } from '@/deps.ts'; type DittoAttachment = TypeFest.SetOptional; From c7b34ed31b895037c01432af2bd5626243a23cc1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:18:28 -0500 Subject: [PATCH 05/14] iso-639-1 alias --- deno.json | 1 + deno.lock | 1 + src/controllers/api/statuses.ts | 2 +- src/deps.ts | 2 -- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index 0bc5d0b..526d43f 100644 --- a/deno.json +++ b/deno.json @@ -28,6 +28,7 @@ "comlink": "npm:comlink@^4.4.1", "hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", + "iso-639-1": "npm:iso-639-1@2.1.15", "kysely": "npm:kysely@^0.27.3", "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts", "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", diff --git a/deno.lock b/deno.lock index eb53807..4a7aa61 100644 --- a/deno.lock +++ b/deno.lock @@ -1508,6 +1508,7 @@ "jsr:@std/media-types@^0.224.0", "jsr:@std/streams@^0.223.0", "npm:comlink@^4.4.1", + "npm:iso-639-1@2.1.15", "npm:kysely@^0.27.3", "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 4292336..2c05dbd 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -1,11 +1,11 @@ import { NIP05, NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import ISO6391 from 'iso-639-1'; import { nip19 } from 'nostr-tools'; import { z } from 'zod'; import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; import { getUnattachedMediaByIds } from '@/db/unattached-media.ts'; -import { ISO6391 } from '@/deps.ts'; import { getAncestors, getAuthor, getDescendants, getEvent } from '@/queries.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { addTag, deleteTag } from '@/tags.ts'; diff --git a/src/deps.ts b/src/deps.ts index 78e90d0..55dc803 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -11,7 +11,6 @@ export { unfurl } from 'npm:unfurl.js@^6.4.0'; export { default as TTLCache } from 'npm:@isaacs/ttlcache@^1.4.1'; // @deno-types="npm:@types/sanitize-html@2.9.0" export { default as sanitizeHtml } from 'npm:sanitize-html@^2.11.0'; -export { default as ISO6391 } from 'npm:iso-639-1@2.1.15'; export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.4/mod.ts'; export { type ParsedSignature, @@ -34,6 +33,5 @@ export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; export { default as uuid62 } from 'npm:uuid62@^1.0.2'; -export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; export { EventEmitter } from 'npm:tseep@^1.1.3'; export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; From 8738aeb8208d6c31ee22c5c6704e35d6bc27775d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:19:53 -0500 Subject: [PATCH 06/14] tldts alias --- deno.json | 1 + src/db/relays.ts | 3 ++- src/deps.ts | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 526d43f..e4f2343 100644 --- a/deno.json +++ b/deno.json @@ -34,6 +34,7 @@ "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", "nostr-wasm": "npm:nostr-wasm@^0.1.0", + "tldts": "npm:tldts@^6.0.14", "type-fest": "npm:type-fest@^4.3.0", "zod": "npm:zod@^3.23.4", "~/fixtures/": "./fixtures/" diff --git a/src/db/relays.ts b/src/db/relays.ts index 836f520..da29b79 100644 --- a/src/db/relays.ts +++ b/src/db/relays.ts @@ -1,4 +1,5 @@ -import { tldts } from '@/deps.ts'; +import tldts from 'tldts'; + import { db } from '@/db.ts'; interface AddRelaysOpts { diff --git a/src/deps.ts b/src/deps.ts index 55dc803..bdab9f4 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -28,7 +28,6 @@ export { } from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts'; export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts'; export * as dotenv from 'https://deno.land/std@0.198.0/dotenv/mod.ts'; -export { default as tldts } from 'npm:tldts@^6.0.14'; export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; From c4d8ad2368f6badab16ba79219acb30460edcecf Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:21:18 -0500 Subject: [PATCH 07/14] uuid62 alias --- deno.json | 1 + src/db/unattached-media.ts | 3 ++- src/deps.ts | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index e4f2343..1cf44e9 100644 --- a/deno.json +++ b/deno.json @@ -36,6 +36,7 @@ "nostr-wasm": "npm:nostr-wasm@^0.1.0", "tldts": "npm:tldts@^6.0.14", "type-fest": "npm:type-fest@^4.3.0", + "uuid62": "npm:uuid62@^1.0.2", "zod": "npm:zod@^3.23.4", "~/fixtures/": "./fixtures/" }, diff --git a/src/db/unattached-media.ts b/src/db/unattached-media.ts index 3761947..21805ba 100644 --- a/src/db/unattached-media.ts +++ b/src/db/unattached-media.ts @@ -1,5 +1,6 @@ +import { uuid62 } from 'uuid62'; + import { db } from '@/db.ts'; -import { uuid62 } from '@/deps.ts'; import { type MediaData } from '@/schemas/nostr.ts'; interface UnattachedMedia { diff --git a/src/deps.ts b/src/deps.ts index bdab9f4..3b770b1 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -31,6 +31,4 @@ export * as dotenv from 'https://deno.land/std@0.198.0/dotenv/mod.ts'; export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; -export { default as uuid62 } from 'npm:uuid62@^1.0.2'; -export { EventEmitter } from 'npm:tseep@^1.1.3'; export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; From ea665eed12516efd61dfc55a616537df845ec760 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:22:55 -0500 Subject: [PATCH 08/14] std/dotenv alias --- deno.json | 1 + deno.lock | 7 +++++++ src/config.ts | 3 +-- src/deps.ts | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index 1cf44e9..9bcdba9 100644 --- a/deno.json +++ b/deno.json @@ -21,6 +21,7 @@ "@soapbox/stickynotes": "jsr:@soapbox/stickynotes@^0.4.0", "@std/cli": "jsr:@std/cli@^0.223.0", "@std/crypto": "jsr:@std/crypto@^0.224.0", + "@std/dotenv": "jsr:@std/dotenv@^0.224.0", "@std/encoding": "jsr:@std/encoding@^0.224.0", "@std/json": "jsr:@std/json@^0.223.0", "@std/media-types": "jsr:@std/media-types@^0.224.0", diff --git a/deno.lock b/deno.lock index 4a7aa61..e948e58 100644 --- a/deno.lock +++ b/deno.lock @@ -7,6 +7,7 @@ "jsr:@soapbox/stickynotes@^0.4.0": "jsr:@soapbox/stickynotes@0.4.0", "jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0", "jsr:@std/crypto@^0.224.0": "jsr:@std/crypto@0.224.0", + "jsr:@std/dotenv@^0.224.0": "jsr:@std/dotenv@0.224.0", "jsr:@std/encoding@^0.224.0": "jsr:@std/encoding@0.224.0", "jsr:@std/media-types@^0.224.0": "jsr:@std/media-types@0.224.0", "npm:@isaacs/ttlcache@^1.4.1": "npm:@isaacs/ttlcache@1.4.1", @@ -82,6 +83,9 @@ "jsr:@std/encoding@^0.224.0" ] }, + "@std/dotenv@0.224.0": { + "integrity": "d9234cdf551507dcda60abb6c474289843741d8c07ee8ce540c60f5c1b220a1d" + }, "@std/encoding@0.224.0": { "integrity": "efb6dca97d3e9c31392bd5c8cfd9f9fc9decf5a1f4d1f78af7900a493bcf89b5" }, @@ -1503,6 +1507,7 @@ "jsr:@soapbox/stickynotes@^0.4.0", "jsr:@std/cli@^0.223.0", "jsr:@std/crypto@^0.224.0", + "jsr:@std/dotenv@^0.224.0", "jsr:@std/encoding@^0.224.0", "jsr:@std/json@^0.223.0", "jsr:@std/media-types@^0.224.0", @@ -1513,7 +1518,9 @@ "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", "npm:nostr-wasm@^0.1.0", + "npm:tldts@^6.0.14", "npm:type-fest@^4.3.0", + "npm:uuid62@^1.0.2", "npm:zod@^3.23.4" ] } diff --git a/src/config.ts b/src/config.ts index 8331f71..2e8004f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,10 +1,9 @@ import url from 'node:url'; +import * as dotenv from '@std/dotenv'; import { getPublicKey, nip19 } from 'nostr-tools'; import { z } from 'zod'; -import { dotenv } from '@/deps.ts'; - /** Load environment config from `.env` */ await dotenv.load({ export: true, diff --git a/src/deps.ts b/src/deps.ts index 3b770b1..d643515 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -27,7 +27,6 @@ export { SqliteError, } from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts'; export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts'; -export * as dotenv from 'https://deno.land/std@0.198.0/dotenv/mod.ts'; export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; From e5c8030960a3cab32fe32ca3c958e37cf2455ca9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:29:21 -0500 Subject: [PATCH 09/14] Move more deps to aliases --- deno.json | 4 ++++ deno.lock | 33 +++++++++++++++++++++++++++++++++ src/deps.ts | 4 ---- src/filter.ts | 2 +- src/storages/reqmeister.ts | 2 +- src/uploaders/s3.ts | 2 +- src/utils/SimpleLRU.ts | 2 +- src/utils/rsa.ts | 4 +++- 8 files changed, 44 insertions(+), 9 deletions(-) diff --git a/deno.json b/deno.json index 9bcdba9..b59d2ea 100644 --- a/deno.json +++ b/deno.json @@ -15,6 +15,7 @@ "exclude": ["./public"], "imports": { "@/": "./src/", + "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", @@ -27,15 +28,18 @@ "@std/media-types": "jsr:@std/media-types@^0.224.0", "@std/streams": "jsr:@std/streams@^0.223.0", "comlink": "npm:comlink@^4.4.1", + "fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0", "hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "iso-639-1": "npm:iso-639-1@2.1.15", "kysely": "npm:kysely@^0.27.3", "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts", + "lru-cache": "npm:lru-cache@^10.2.2", "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", "nostr-wasm": "npm:nostr-wasm@^0.1.0", "tldts": "npm:tldts@^6.0.14", + "tseep": "npm:tseep@^1.2.1", "type-fest": "npm:type-fest@^4.3.0", "uuid62": "npm:uuid62@^1.0.2", "zod": "npm:zod@^3.23.4", diff --git a/deno.lock b/deno.lock index e948e58..bb494f5 100644 --- a/deno.lock +++ b/deno.lock @@ -2,13 +2,17 @@ "version": "3", "packages": { "specifiers": { + "jsr:@bradenmacdonald/s3-lite-client@^0.7.4": "jsr:@bradenmacdonald/s3-lite-client@0.7.4", "jsr:@nostrify/nostrify@^0.15.0": "jsr:@nostrify/nostrify@0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2": "jsr:@soapbox/kysely-deno-sqlite@2.0.2", "jsr:@soapbox/stickynotes@^0.4.0": "jsr:@soapbox/stickynotes@0.4.0", + "jsr:@std/assert@^0.218.2": "jsr:@std/assert@0.218.2", "jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0", + "jsr:@std/bytes@^0.218.2": "jsr:@std/bytes@0.218.2", "jsr:@std/crypto@^0.224.0": "jsr:@std/crypto@0.224.0", "jsr:@std/dotenv@^0.224.0": "jsr:@std/dotenv@0.224.0", "jsr:@std/encoding@^0.224.0": "jsr:@std/encoding@0.224.0", + "jsr:@std/io@^0.218": "jsr:@std/io@0.218.2", "jsr:@std/media-types@^0.224.0": "jsr:@std/media-types@0.224.0", "npm:@isaacs/ttlcache@^1.4.1": "npm:@isaacs/ttlcache@1.4.1", "npm:@noble/hashes@^1.4.0": "npm:@noble/hashes@1.4.0", @@ -32,6 +36,7 @@ "npm:linkify-string@^4.1.1": "npm:linkify-string@4.1.3_linkifyjs@4.1.3", "npm:linkifyjs@^4.1.1": "npm:linkifyjs@4.1.3", "npm:lru-cache@^10.2.0": "npm:lru-cache@10.2.0", + "npm:lru-cache@^10.2.2": "npm:lru-cache@10.2.2", "npm:mime@^3.0.0": "npm:mime@3.0.0", "npm:node-forge@^1.3.1": "npm:node-forge@1.3.1", "npm:nostr-relaypool2@0.6.34": "npm:nostr-relaypool2@0.6.34", @@ -42,6 +47,7 @@ "npm:sanitize-html@^2.11.0": "npm:sanitize-html@2.13.0", "npm:tldts@^6.0.14": "npm:tldts@6.1.18", "npm:tseep@^1.1.3": "npm:tseep@1.2.1", + "npm:tseep@^1.2.1": "npm:tseep@1.2.1", "npm:type-fest@^4.3.0": "npm:type-fest@4.15.0", "npm:unfurl.js@^6.4.0": "npm:unfurl.js@6.4.0", "npm:uuid62@^1.0.2": "npm:uuid62@1.0.2", @@ -50,6 +56,12 @@ "npm:zod@^3.23.4": "npm:zod@3.23.4" }, "jsr": { + "@bradenmacdonald/s3-lite-client@0.7.4": { + "integrity": "602666ef40d09621d35aa3ea8813e0bfd58b3558e3f0a1d20404b0e61aa0b37e", + "dependencies": [ + "jsr:@std/io@^0.218" + ] + }, "@nostrify/nostrify@0.15.0": { "integrity": "51c2fe9ac7264d22567cd1919a5bf5101a5207f651e65bc00b3de43f9038dfc8", "dependencies": [ @@ -73,9 +85,15 @@ "@soapbox/stickynotes@0.4.0": { "integrity": "60bfe61ab3d7e04bf708273b1e2d391a59534bdf29e54160e98d7afd328ca1ec" }, + "@std/assert@0.218.2": { + "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" + }, "@std/assert@0.224.0": { "integrity": "8643233ec7aec38a940a8264a6e3eed9bfa44e7a71cc6b3c8874213ff401967f" }, + "@std/bytes@0.218.2": { + "integrity": "91fe54b232dcca73856b79a817247f4a651dbb60d51baafafb6408c137241670" + }, "@std/crypto@0.224.0": { "integrity": "154ef3ff08ef535562ef1a718718c5b2c5fc3808f0f9100daad69e829bfcdf2d", "dependencies": [ @@ -89,6 +107,13 @@ "@std/encoding@0.224.0": { "integrity": "efb6dca97d3e9c31392bd5c8cfd9f9fc9decf5a1f4d1f78af7900a493bcf89b5" }, + "@std/io@0.218.2": { + "integrity": "c64fbfa087b7c9d4d386c5672f291f607d88cb7d44fc299c20c713e345f2785f", + "dependencies": [ + "jsr:@std/assert@^0.218.2", + "jsr:@std/bytes@^0.218.2" + ] + }, "@std/media-types@0.224.0": { "integrity": "5ac87989393f8cb1c81bee02aef6f5d4c8289b416deabc04f9ad25dff292d0b0" } @@ -686,6 +711,10 @@ "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "dependencies": {} }, + "lru-cache@10.2.2": { + "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", + "dependencies": {} + }, "lru-cache@6.0.0": { "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dependencies": { @@ -1502,6 +1531,7 @@ }, "workspace": { "dependencies": [ + "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", "jsr:@nostrify/nostrify@^0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", "jsr:@soapbox/stickynotes@^0.4.0", @@ -1513,12 +1543,15 @@ "jsr:@std/media-types@^0.224.0", "jsr:@std/streams@^0.223.0", "npm:comlink@^4.4.1", + "npm:fast-stable-stringify@^1.0.0", "npm:iso-639-1@2.1.15", "npm:kysely@^0.27.3", + "npm:lru-cache@^10.2.2", "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", "npm:nostr-wasm@^0.1.0", "npm:tldts@^6.0.14", + "npm:tseep@^1.2.1", "npm:type-fest@^4.3.0", "npm:uuid62@^1.0.2", "npm:zod@^3.23.4" diff --git a/src/deps.ts b/src/deps.ts index d643515..ae268f5 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -21,13 +21,9 @@ export { } from 'https://gitlab.com/soapbox-pub/fedisign/-/raw/v0.2.1/mod.ts'; export { generateSeededRsa } from 'https://gitlab.com/soapbox-pub/seeded-rsa/-/raw/v1.0.0/mod.ts'; export * as secp from 'npm:@noble/secp256k1@^2.0.0'; -export { LRUCache } from 'npm:lru-cache@^10.2.0'; export { DB as Sqlite, SqliteError, } from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts'; export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts'; export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; -export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; -export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; -export { default as stringifyStable } from 'npm:fast-stable-stringify@^1.0.0'; diff --git a/src/filter.ts b/src/filter.ts index 9e99c4a..3bb18a6 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,7 +1,7 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; +import { stringifyStable } from 'fast-stable-stringify'; import { z } from 'zod'; -import { stringifyStable } from '@/deps.ts'; import { isReplaceableKind } from '@/kinds.ts'; import { nostrIdSchema } from '@/schemas/nostr.ts'; diff --git a/src/storages/reqmeister.ts b/src/storages/reqmeister.ts index a385ec9..eede200 100644 --- a/src/storages/reqmeister.ts +++ b/src/storages/reqmeister.ts @@ -1,7 +1,7 @@ import { NostrEvent, NostrFilter, NStore } from '@nostrify/nostrify'; import Debug from '@soapbox/stickynotes/debug'; +import { EventEmitter } from 'tseep'; -import { EventEmitter } from '@/deps.ts'; import { eventToMicroFilter, getFilterId, isMicrofilter, type MicroFilter } from '@/filter.ts'; import { Time } from '@/utils/time.ts'; import { abortError } from '@/utils/abort.ts'; diff --git a/src/uploaders/s3.ts b/src/uploaders/s3.ts index 29f3043..267d817 100644 --- a/src/uploaders/s3.ts +++ b/src/uploaders/s3.ts @@ -1,11 +1,11 @@ import { join } from 'node:path'; +import { S3Client } from '@bradenmacdonald/s3-lite-client'; import { crypto } from '@std/crypto'; import { encodeHex } from '@std/encoding/hex'; import { extensionsByType } from '@std/media-types'; import { Conf } from '@/config.ts'; -import { S3Client } from '@/deps.ts'; import type { Uploader } from './types.ts'; diff --git a/src/utils/SimpleLRU.ts b/src/utils/SimpleLRU.ts index 26f51fc..f1bf651 100644 --- a/src/utils/SimpleLRU.ts +++ b/src/utils/SimpleLRU.ts @@ -1,6 +1,6 @@ // deno-lint-ignore-file ban-types -import { LRUCache } from '@/deps.ts'; +import { LRUCache } from 'lru-cache'; type FetchFn = (key: K, opts: O) => Promise; diff --git a/src/utils/rsa.ts b/src/utils/rsa.ts index 9155a72..0d3a588 100644 --- a/src/utils/rsa.ts +++ b/src/utils/rsa.ts @@ -1,5 +1,7 @@ +import { LRUCache } from 'lru-cache'; + import { Conf } from '@/config.ts'; -import { generateSeededRsa, LRUCache, publicKeyToPem, secp } from '@/deps.ts'; +import { generateSeededRsa, publicKeyToPem, secp } from '@/deps.ts'; const opts = { bits: 2048, From 5a7a409981229b7091147fbdbe9a21e3d1f514aa Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:34:16 -0500 Subject: [PATCH 10/14] Alias unfurl, linkifyjs etc --- deno.json | 5 +++++ deno.lock | 5 +++++ src/deps.ts | 6 ------ src/note.ts | 5 ++++- src/utils/unfurl.ts | 4 +++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/deno.json b/deno.json index b59d2ea..0199621 100644 --- a/deno.json +++ b/deno.json @@ -16,6 +16,7 @@ "imports": { "@/": "./src/", "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", + "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", @@ -34,6 +35,9 @@ "iso-639-1": "npm:iso-639-1@2.1.15", "kysely": "npm:kysely@^0.27.3", "kysely_deno_postgres": "https://deno.land/x/kysely_deno_postgres@v0.4.0/mod.ts", + "linkify-plugin-hashtag": "npm:linkify-plugin-hashtag@^4.1.1", + "linkify-string": "npm:linkify-string@^4.1.1", + "linkifyjs": "npm:linkifyjs@^4.1.1", "lru-cache": "npm:lru-cache@^10.2.2", "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", @@ -41,6 +45,7 @@ "tldts": "npm:tldts@^6.0.14", "tseep": "npm:tseep@^1.2.1", "type-fest": "npm:type-fest@^4.3.0", + "unfurl": "npm:unfurl.js@^6.4.0", "uuid62": "npm:uuid62@^1.0.2", "zod": "npm:zod@^3.23.4", "~/fixtures/": "./fixtures/" diff --git a/deno.lock b/deno.lock index bb494f5..9cf2645 100644 --- a/deno.lock +++ b/deno.lock @@ -1542,10 +1542,14 @@ "jsr:@std/json@^0.223.0", "jsr:@std/media-types@^0.224.0", "jsr:@std/streams@^0.223.0", + "npm:@isaacs/ttlcache@^1.4.1", "npm:comlink@^4.4.1", "npm:fast-stable-stringify@^1.0.0", "npm:iso-639-1@2.1.15", "npm:kysely@^0.27.3", + "npm:linkify-plugin-hashtag@^4.1.1", + "npm:linkify-string@^4.1.1", + "npm:linkifyjs@^4.1.1", "npm:lru-cache@^10.2.2", "npm:nostr-relaypool2@0.6.34", "npm:nostr-tools@^2.5.1", @@ -1553,6 +1557,7 @@ "npm:tldts@^6.0.14", "npm:tseep@^1.2.1", "npm:type-fest@^4.3.0", + "npm:unfurl.js@^6.4.0", "npm:uuid62@^1.0.2", "npm:zod@^3.23.4" ] diff --git a/src/deps.ts b/src/deps.ts index ae268f5..2eb367f 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -2,16 +2,10 @@ import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts'; export { parseFormData } from 'npm:formdata-helper@^0.3.0'; // @deno-types="npm:@types/lodash@4.14.194" export { default as lodash } from 'https://esm.sh/lodash@4.17.21'; -export { default as linkify } from 'npm:linkifyjs@^4.1.1'; -export { default as linkifyStr } from 'npm:linkify-string@^4.1.1'; -import 'npm:linkify-plugin-hashtag@^4.1.1'; // @deno-types="npm:@types/mime@3.0.0" export { default as mime } from 'npm:mime@^3.0.0'; -export { unfurl } from 'npm:unfurl.js@^6.4.0'; -export { default as TTLCache } from 'npm:@isaacs/ttlcache@^1.4.1'; // @deno-types="npm:@types/sanitize-html@2.9.0" export { default as sanitizeHtml } from 'npm:sanitize-html@^2.11.0'; -export { createPentagon } from 'https://deno.land/x/pentagon@v0.1.4/mod.ts'; export { type ParsedSignature, pemToPublicKey, diff --git a/src/note.ts b/src/note.ts index fe03d7f..5603c53 100644 --- a/src/note.ts +++ b/src/note.ts @@ -1,7 +1,10 @@ +import 'linkify-plugin-hashtag'; +import linkifyStr from 'linkify-string'; +import linkify from 'linkifyjs'; import { nip19, nip21 } from 'nostr-tools'; import { Conf } from '@/config.ts'; -import { linkify, linkifyStr, mime } from '@/deps.ts'; +import { mime } from '@/deps.ts'; import { type DittoAttachment } from '@/views/mastodon/attachments.ts'; linkify.registerCustomProtocol('nostr', true); diff --git a/src/utils/unfurl.ts b/src/utils/unfurl.ts index bde5561..22c69b1 100644 --- a/src/utils/unfurl.ts +++ b/src/utils/unfurl.ts @@ -1,6 +1,8 @@ +import TTLCache from '@isaacs/ttlcache'; import Debug from '@soapbox/stickynotes/debug'; +import { unfurl } from 'unfurl'; -import { sanitizeHtml, TTLCache, unfurl } from '@/deps.ts'; +import { sanitizeHtml } from '@/deps.ts'; import { Time } from '@/utils/time.ts'; import { fetchWorker } from '@/workers/fetch.ts'; From d1f643d7ad9bf7936641242d7afe1e16dfcc38f7 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:35:39 -0500 Subject: [PATCH 11/14] secp256k1 alias --- deno.json | 1 + deno.lock | 1 + src/deps.ts | 1 - src/utils/rsa.ts | 3 ++- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 0199621..9ea8d73 100644 --- a/deno.json +++ b/deno.json @@ -17,6 +17,7 @@ "@/": "./src/", "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", + "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", "@sentry/deno": "https://deno.land/x/sentry@7.112.2/index.mjs", "@soapbox/kysely-deno-sqlite": "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", diff --git a/deno.lock b/deno.lock index 9cf2645..e568a59 100644 --- a/deno.lock +++ b/deno.lock @@ -1543,6 +1543,7 @@ "jsr:@std/media-types@^0.224.0", "jsr:@std/streams@^0.223.0", "npm:@isaacs/ttlcache@^1.4.1", + "npm:@noble/secp256k1@^2.0.0", "npm:comlink@^4.4.1", "npm:fast-stable-stringify@^1.0.0", "npm:iso-639-1@2.1.15", diff --git a/src/deps.ts b/src/deps.ts index 2eb367f..09eb5b5 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -14,7 +14,6 @@ export { verifyRequest, } from 'https://gitlab.com/soapbox-pub/fedisign/-/raw/v0.2.1/mod.ts'; export { generateSeededRsa } from 'https://gitlab.com/soapbox-pub/seeded-rsa/-/raw/v1.0.0/mod.ts'; -export * as secp from 'npm:@noble/secp256k1@^2.0.0'; export { DB as Sqlite, SqliteError, diff --git a/src/utils/rsa.ts b/src/utils/rsa.ts index 0d3a588..6942c43 100644 --- a/src/utils/rsa.ts +++ b/src/utils/rsa.ts @@ -1,7 +1,8 @@ +import * as secp from '@noble/secp256k1'; import { LRUCache } from 'lru-cache'; import { Conf } from '@/config.ts'; -import { generateSeededRsa, publicKeyToPem, secp } from '@/deps.ts'; +import { generateSeededRsa, publicKeyToPem } from '@/deps.ts'; const opts = { bits: 2048, From 08ed52a57b5d37bc5a336a146dc8f7287eaddefc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:37:01 -0500 Subject: [PATCH 12/14] formdata-helper alias --- deno.json | 1 + deno.lock | 1 + src/deps.ts | 2 -- src/utils/api.ts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index 9ea8d73..24bc364 100644 --- a/deno.json +++ b/deno.json @@ -31,6 +31,7 @@ "@std/streams": "jsr:@std/streams@^0.223.0", "comlink": "npm:comlink@^4.4.1", "fast-stable-stringify": "npm:fast-stable-stringify@^1.0.0", + "formdata-helper": "npm:formdata-helper@^0.3.0", "hono": "https://deno.land/x/hono@v3.10.1/mod.ts", "hono/middleware": "https://deno.land/x/hono@v3.10.1/middleware.ts", "iso-639-1": "npm:iso-639-1@2.1.15", diff --git a/deno.lock b/deno.lock index e568a59..494d289 100644 --- a/deno.lock +++ b/deno.lock @@ -1546,6 +1546,7 @@ "npm:@noble/secp256k1@^2.0.0", "npm:comlink@^4.4.1", "npm:fast-stable-stringify@^1.0.0", + "npm:formdata-helper@^0.3.0", "npm:iso-639-1@2.1.15", "npm:kysely@^0.27.3", "npm:linkify-plugin-hashtag@^4.1.1", diff --git a/src/deps.ts b/src/deps.ts index 09eb5b5..1672365 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,5 +1,4 @@ import 'https://gitlab.com/soapbox-pub/deno-safe-fetch/-/raw/v1.0.0/load.ts'; -export { parseFormData } from 'npm:formdata-helper@^0.3.0'; // @deno-types="npm:@types/lodash@4.14.194" export { default as lodash } from 'https://esm.sh/lodash@4.17.21'; // @deno-types="npm:@types/mime@3.0.0" @@ -19,4 +18,3 @@ export { SqliteError, } from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts'; export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts'; -export * as cron from 'https://deno.land/x/deno_cron@v1.0.0/cron.ts'; diff --git a/src/utils/api.ts b/src/utils/api.ts index 85d5783..72f4c3e 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,13 +1,13 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; import Debug from '@soapbox/stickynotes/debug'; import { type Context, HTTPException } from 'hono'; +import { parseFormData } from 'formdata-helper'; import { EventTemplate } from 'nostr-tools'; import * as TypeFest from 'type-fest'; import { z } from 'zod'; import { type AppContext } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { parseFormData } from '@/deps.ts'; import * as pipeline from '@/pipeline.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { APISigner } from '@/signers/APISigner.ts'; From 7de5cdc18d1397dab224b72e91bc6aa58037f19f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:40:58 -0500 Subject: [PATCH 13/14] @db/sqlite, scoped_performance aliases --- deno.json | 2 ++ src/deps.ts | 2 -- src/workers/sqlite.worker.ts | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deno.json b/deno.json index 24bc364..ca05ab0 100644 --- a/deno.json +++ b/deno.json @@ -16,6 +16,7 @@ "imports": { "@/": "./src/", "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", + "@db/sqlite": "jsr:@db/sqlite@^0.11.1", "@isaacs/ttlcache": "npm:@isaacs/ttlcache@^1.4.1", "@noble/secp256k1": "npm:@noble/secp256k1@^2.0.0", "@nostrify/nostrify": "jsr:@nostrify/nostrify@^0.15.0", @@ -44,6 +45,7 @@ "nostr-relaypool": "npm:nostr-relaypool2@0.6.34", "nostr-tools": "npm:nostr-tools@^2.5.1", "nostr-wasm": "npm:nostr-wasm@^0.1.0", + "scoped_performance" :"https://deno.land/x/scoped_performance@v2.0.0/mod.ts", "tldts": "npm:tldts@^6.0.14", "tseep": "npm:tseep@^1.2.1", "type-fest": "npm:type-fest@^4.3.0", diff --git a/src/deps.ts b/src/deps.ts index 1672365..7a8fa9a 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -15,6 +15,4 @@ export { export { generateSeededRsa } from 'https://gitlab.com/soapbox-pub/seeded-rsa/-/raw/v1.0.0/mod.ts'; export { DB as Sqlite, - SqliteError, } from 'https://raw.githubusercontent.com/alexgleason/deno-sqlite/325f66d8c395e7f6f5ee78ebfa42a0eeea4a942b/mod.ts'; -export { Database as DenoSqlite3 } from 'https://deno.land/x/sqlite3@0.9.1/mod.ts'; diff --git a/src/workers/sqlite.worker.ts b/src/workers/sqlite.worker.ts index df9d6f0..a3ff1d6 100644 --- a/src/workers/sqlite.worker.ts +++ b/src/workers/sqlite.worker.ts @@ -1,18 +1,18 @@ /// -import { ScopedPerformance } from 'https://deno.land/x/scoped_performance@v2.0.0/mod.ts'; +import { Database as SQLite } from '@db/sqlite'; import { Stickynotes } from '@soapbox/stickynotes'; import * as Comlink from 'comlink'; import { CompiledQuery, QueryResult } from 'kysely'; +import { ScopedPerformance } from 'scoped_performance'; -import { DenoSqlite3 } from '@/deps.ts'; import '@/sentry.ts'; -let db: DenoSqlite3 | undefined; +let db: SQLite | undefined; const console = new Stickynotes('ditto:sqlite.worker'); export const SqliteWorker = { open(path: string): void { - db = new DenoSqlite3(path); + db = new SQLite(path); }, executeQuery({ sql, parameters }: CompiledQuery): QueryResult { if (!db) throw new Error('Database not open'); From 8959f85afbc7619be9b12eaa403e043646ea1194 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 May 2024 16:42:07 -0500 Subject: [PATCH 14/14] Fix imports of uuid62 and fast-stringify-stable --- deno.lock | 57 ++++++++++++++++++++++++++++++++++++++ src/db/unattached-media.ts | 2 +- src/filter.ts | 2 +- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/deno.lock b/deno.lock index 494d289..554ca0b 100644 --- a/deno.lock +++ b/deno.lock @@ -3,17 +3,26 @@ "packages": { "specifiers": { "jsr:@bradenmacdonald/s3-lite-client@^0.7.4": "jsr:@bradenmacdonald/s3-lite-client@0.7.4", + "jsr:@db/sqlite@^0.11.1": "jsr:@db/sqlite@0.11.1", + "jsr:@denosaurs/plug@1": "jsr:@denosaurs/plug@1.0.6", "jsr:@nostrify/nostrify@^0.15.0": "jsr:@nostrify/nostrify@0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2": "jsr:@soapbox/kysely-deno-sqlite@2.0.2", "jsr:@soapbox/stickynotes@^0.4.0": "jsr:@soapbox/stickynotes@0.4.0", + "jsr:@std/assert@^0.217.0": "jsr:@std/assert@0.217.0", "jsr:@std/assert@^0.218.2": "jsr:@std/assert@0.218.2", + "jsr:@std/assert@^0.221.0": "jsr:@std/assert@0.221.0", "jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0", "jsr:@std/bytes@^0.218.2": "jsr:@std/bytes@0.218.2", "jsr:@std/crypto@^0.224.0": "jsr:@std/crypto@0.224.0", "jsr:@std/dotenv@^0.224.0": "jsr:@std/dotenv@0.224.0", + "jsr:@std/encoding@^0.221.0": "jsr:@std/encoding@0.221.0", "jsr:@std/encoding@^0.224.0": "jsr:@std/encoding@0.224.0", + "jsr:@std/fmt@^0.221.0": "jsr:@std/fmt@0.221.0", + "jsr:@std/fs@^0.221.0": "jsr:@std/fs@0.221.0", "jsr:@std/io@^0.218": "jsr:@std/io@0.218.2", "jsr:@std/media-types@^0.224.0": "jsr:@std/media-types@0.224.0", + "jsr:@std/path@0.217": "jsr:@std/path@0.217.0", + "jsr:@std/path@^0.221.0": "jsr:@std/path@0.221.0", "npm:@isaacs/ttlcache@^1.4.1": "npm:@isaacs/ttlcache@1.4.1", "npm:@noble/hashes@^1.4.0": "npm:@noble/hashes@1.4.0", "npm:@noble/secp256k1@^2.0.0": "npm:@noble/secp256k1@2.1.0", @@ -62,6 +71,22 @@ "jsr:@std/io@^0.218" ] }, + "@db/sqlite@0.11.1": { + "integrity": "546434e7ed762db07e6ade0f963540dd5e06723b802937bf260ff855b21ef9c5", + "dependencies": [ + "jsr:@denosaurs/plug@1", + "jsr:@std/path@0.217" + ] + }, + "@denosaurs/plug@1.0.6": { + "integrity": "6cf5b9daba7799837b9ffbe89f3450510f588fafef8115ddab1ff0be9cb7c1a7", + "dependencies": [ + "jsr:@std/encoding@^0.221.0", + "jsr:@std/fmt@^0.221.0", + "jsr:@std/fs@^0.221.0", + "jsr:@std/path@^0.221.0" + ] + }, "@nostrify/nostrify@0.15.0": { "integrity": "51c2fe9ac7264d22567cd1919a5bf5101a5207f651e65bc00b3de43f9038dfc8", "dependencies": [ @@ -85,9 +110,15 @@ "@soapbox/stickynotes@0.4.0": { "integrity": "60bfe61ab3d7e04bf708273b1e2d391a59534bdf29e54160e98d7afd328ca1ec" }, + "@std/assert@0.217.0": { + "integrity": "c98e279362ca6982d5285c3b89517b757c1e3477ee9f14eb2fdf80a45aaa9642" + }, "@std/assert@0.218.2": { "integrity": "7f0a5a1a8cf86607cd6c2c030584096e1ffad27fc9271429a8cb48cfbdee5eaf" }, + "@std/assert@0.221.0": { + "integrity": "a5f1aa6e7909dbea271754fd4ab3f4e687aeff4873b4cef9a320af813adb489a" + }, "@std/assert@0.224.0": { "integrity": "8643233ec7aec38a940a8264a6e3eed9bfa44e7a71cc6b3c8874213ff401967f" }, @@ -104,9 +135,22 @@ "@std/dotenv@0.224.0": { "integrity": "d9234cdf551507dcda60abb6c474289843741d8c07ee8ce540c60f5c1b220a1d" }, + "@std/encoding@0.221.0": { + "integrity": "d1dd76ef0dc5d14088411e6dc1dede53bf8308c95d1537df1214c97137208e45" + }, "@std/encoding@0.224.0": { "integrity": "efb6dca97d3e9c31392bd5c8cfd9f9fc9decf5a1f4d1f78af7900a493bcf89b5" }, + "@std/fmt@0.221.0": { + "integrity": "379fed69bdd9731110f26b9085aeb740606b20428ce6af31ef6bd45ef8efa62a" + }, + "@std/fs@0.221.0": { + "integrity": "028044450299de8ed5a716ade4e6d524399f035513b85913794f4e81f07da286", + "dependencies": [ + "jsr:@std/assert@^0.221.0", + "jsr:@std/path@^0.221.0" + ] + }, "@std/io@0.218.2": { "integrity": "c64fbfa087b7c9d4d386c5672f291f607d88cb7d44fc299c20c713e345f2785f", "dependencies": [ @@ -116,6 +160,18 @@ }, "@std/media-types@0.224.0": { "integrity": "5ac87989393f8cb1c81bee02aef6f5d4c8289b416deabc04f9ad25dff292d0b0" + }, + "@std/path@0.217.0": { + "integrity": "1217cc25534bca9a2f672d7fe7c6f356e4027df400c0e85c0ef3e4343bc67d11", + "dependencies": [ + "jsr:@std/assert@^0.217.0" + ] + }, + "@std/path@0.221.0": { + "integrity": "0a36f6b17314ef653a3a1649740cc8db51b25a133ecfe838f20b79a56ebe0095", + "dependencies": [ + "jsr:@std/assert@^0.221.0" + ] } }, "npm": { @@ -1532,6 +1588,7 @@ "workspace": { "dependencies": [ "jsr:@bradenmacdonald/s3-lite-client@^0.7.4", + "jsr:@db/sqlite@^0.11.1", "jsr:@nostrify/nostrify@^0.15.0", "jsr:@soapbox/kysely-deno-sqlite@^2.0.2", "jsr:@soapbox/stickynotes@^0.4.0", diff --git a/src/db/unattached-media.ts b/src/db/unattached-media.ts index 21805ba..415c110 100644 --- a/src/db/unattached-media.ts +++ b/src/db/unattached-media.ts @@ -1,4 +1,4 @@ -import { uuid62 } from 'uuid62'; +import uuid62 from 'uuid62'; import { db } from '@/db.ts'; import { type MediaData } from '@/schemas/nostr.ts'; diff --git a/src/filter.ts b/src/filter.ts index 3bb18a6..6247378 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -1,5 +1,5 @@ import { NostrEvent, NostrFilter } from '@nostrify/nostrify'; -import { stringifyStable } from 'fast-stable-stringify'; +import stringifyStable from 'fast-stable-stringify'; import { z } from 'zod'; import { isReplaceableKind } from '@/kinds.ts';