From 6f6e87525e9b7124e52af8fc2451e57cdbd62828 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 19 May 2024 15:57:04 -0500 Subject: [PATCH] Remove DittoUploader interface in favor of NUploader --- src/app.ts | 5 ++--- src/interfaces/DittoUploader.ts | 3 --- src/uploaders/DenoUploader.ts | 5 ++--- src/uploaders/IPFSUploader.ts | 5 ++--- src/uploaders/S3Uploader.ts | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) delete mode 100644 src/interfaces/DittoUploader.ts diff --git a/src/app.ts b/src/app.ts index ddc9990..5300b48 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import { NostrEvent, NostrSigner, NStore } from '@nostrify/nostrify'; +import { NostrEvent, NostrSigner, NStore, NUploader } 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'; @@ -81,7 +81,6 @@ import { hostMetaController } from '@/controllers/well-known/host-meta.ts'; import { nodeInfoController, nodeInfoSchemaController } from '@/controllers/well-known/nodeinfo.ts'; import { nostrController } from '@/controllers/well-known/nostr.ts'; import { webfingerController } from '@/controllers/well-known/webfinger.ts'; -import { DittoUploader } from '@/interfaces/DittoUploader.ts'; import { auth98Middleware, requireProof, requireRole } from '@/middleware/auth98Middleware.ts'; import { cacheMiddleware } from '@/middleware/cacheMiddleware.ts'; import { cspMiddleware } from '@/middleware/cspMiddleware.ts'; @@ -97,7 +96,7 @@ interface AppEnv extends HonoEnv { /** Signer to get the logged-in user's pubkey, relays, and to sign events, or `undefined` if the user isn't logged in. */ signer?: NostrSigner; /** Uploader for the user to upload files. */ - uploader?: DittoUploader; + uploader?: NUploader; /** NIP-98 signed event proving the pubkey is owned by the user. */ proof?: NostrEvent; /** Store */ diff --git a/src/interfaces/DittoUploader.ts b/src/interfaces/DittoUploader.ts deleted file mode 100644 index 08cbf50..0000000 --- a/src/interfaces/DittoUploader.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface DittoUploader { - upload(file: File, opts?: { signal?: AbortSignal }): Promise<[['url', string], ...string[][]]>; -} diff --git a/src/uploaders/DenoUploader.ts b/src/uploaders/DenoUploader.ts index e2224ab..fd30d8c 100644 --- a/src/uploaders/DenoUploader.ts +++ b/src/uploaders/DenoUploader.ts @@ -1,18 +1,17 @@ import { join } from 'node:path'; +import { NUploader } from '@nostrify/nostrify'; import { crypto } from '@std/crypto'; import { encodeHex } from '@std/encoding/hex'; import { extensionsByType } from '@std/media-types'; -import { DittoUploader } from '@/interfaces/DittoUploader.ts'; - export interface DenoUploaderOpts { baseUrl: string; dir: string; } /** Local Deno filesystem uploader. */ -export class DenoUploader implements DittoUploader { +export class DenoUploader implements NUploader { baseUrl: string; dir: string; diff --git a/src/uploaders/IPFSUploader.ts b/src/uploaders/IPFSUploader.ts index 9141e78..7bf5165 100644 --- a/src/uploaders/IPFSUploader.ts +++ b/src/uploaders/IPFSUploader.ts @@ -1,7 +1,6 @@ +import { NUploader } from '@nostrify/nostrify'; import { z } from 'zod'; -import { DittoUploader } from '@/interfaces/DittoUploader.ts'; - export interface IPFSUploaderOpts { baseUrl: string; apiUrl?: string; @@ -13,7 +12,7 @@ export interface IPFSUploaderOpts { * It will try to connect to `http://localhost:5001` by default, * and upload the file using the REST API. */ -export class IPFSUploader implements DittoUploader { +export class IPFSUploader implements NUploader { private baseUrl: string; private apiUrl: string; private fetch: typeof fetch; diff --git a/src/uploaders/S3Uploader.ts b/src/uploaders/S3Uploader.ts index f210ce8..b74796a 100644 --- a/src/uploaders/S3Uploader.ts +++ b/src/uploaders/S3Uploader.ts @@ -1,12 +1,12 @@ import { join } from 'node:path'; import { S3Client } from '@bradenmacdonald/s3-lite-client'; +import { NUploader } from '@nostrify/nostrify'; import { crypto } from '@std/crypto'; import { encodeHex } from '@std/encoding/hex'; import { extensionsByType } from '@std/media-types'; import { Conf } from '@/config.ts'; -import { DittoUploader } from '@/interfaces/DittoUploader.ts'; export interface S3UploaderOpts { endPoint: string; @@ -21,7 +21,7 @@ export interface S3UploaderOpts { } /** S3-compatible uploader for AWS, Wasabi, DigitalOcean Spaces, and more. */ -export class S3Uploader implements DittoUploader { +export class S3Uploader implements NUploader { private client: S3Client; constructor(opts: S3UploaderOpts) {