Remove DittoUploader interface in favor of NUploader

This commit is contained in:
Alex Gleason 2024-05-19 15:57:04 -05:00
parent 0541287f0e
commit 6f6e87525e
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
5 changed files with 8 additions and 14 deletions

View File

@ -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 Debug from '@soapbox/stickynotes/debug';
import { type Context, Env as HonoEnv, type Handler, Hono, Input as HonoInput, type MiddlewareHandler } from 'hono'; import { type Context, Env as HonoEnv, type Handler, Hono, Input as HonoInput, type MiddlewareHandler } from 'hono';
import { cors, logger, serveStatic } from 'hono/middleware'; 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 { nodeInfoController, nodeInfoSchemaController } from '@/controllers/well-known/nodeinfo.ts';
import { nostrController } from '@/controllers/well-known/nostr.ts'; import { nostrController } from '@/controllers/well-known/nostr.ts';
import { webfingerController } from '@/controllers/well-known/webfinger.ts'; import { webfingerController } from '@/controllers/well-known/webfinger.ts';
import { DittoUploader } from '@/interfaces/DittoUploader.ts';
import { auth98Middleware, requireProof, requireRole } from '@/middleware/auth98Middleware.ts'; import { auth98Middleware, requireProof, requireRole } from '@/middleware/auth98Middleware.ts';
import { cacheMiddleware } from '@/middleware/cacheMiddleware.ts'; import { cacheMiddleware } from '@/middleware/cacheMiddleware.ts';
import { cspMiddleware } from '@/middleware/cspMiddleware.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 to get the logged-in user's pubkey, relays, and to sign events, or `undefined` if the user isn't logged in. */
signer?: NostrSigner; signer?: NostrSigner;
/** Uploader for the user to upload files. */ /** Uploader for the user to upload files. */
uploader?: DittoUploader; uploader?: NUploader;
/** NIP-98 signed event proving the pubkey is owned by the user. */ /** NIP-98 signed event proving the pubkey is owned by the user. */
proof?: NostrEvent; proof?: NostrEvent;
/** Store */ /** Store */

View File

@ -1,3 +0,0 @@
export interface DittoUploader {
upload(file: File, opts?: { signal?: AbortSignal }): Promise<[['url', string], ...string[][]]>;
}

View File

@ -1,18 +1,17 @@
import { join } from 'node:path'; import { join } from 'node:path';
import { NUploader } from '@nostrify/nostrify';
import { crypto } from '@std/crypto'; import { crypto } from '@std/crypto';
import { encodeHex } from '@std/encoding/hex'; import { encodeHex } from '@std/encoding/hex';
import { extensionsByType } from '@std/media-types'; import { extensionsByType } from '@std/media-types';
import { DittoUploader } from '@/interfaces/DittoUploader.ts';
export interface DenoUploaderOpts { export interface DenoUploaderOpts {
baseUrl: string; baseUrl: string;
dir: string; dir: string;
} }
/** Local Deno filesystem uploader. */ /** Local Deno filesystem uploader. */
export class DenoUploader implements DittoUploader { export class DenoUploader implements NUploader {
baseUrl: string; baseUrl: string;
dir: string; dir: string;

View File

@ -1,7 +1,6 @@
import { NUploader } from '@nostrify/nostrify';
import { z } from 'zod'; import { z } from 'zod';
import { DittoUploader } from '@/interfaces/DittoUploader.ts';
export interface IPFSUploaderOpts { export interface IPFSUploaderOpts {
baseUrl: string; baseUrl: string;
apiUrl?: string; apiUrl?: string;
@ -13,7 +12,7 @@ export interface IPFSUploaderOpts {
* It will try to connect to `http://localhost:5001` by default, * It will try to connect to `http://localhost:5001` by default,
* and upload the file using the REST API. * and upload the file using the REST API.
*/ */
export class IPFSUploader implements DittoUploader { export class IPFSUploader implements NUploader {
private baseUrl: string; private baseUrl: string;
private apiUrl: string; private apiUrl: string;
private fetch: typeof fetch; private fetch: typeof fetch;

View File

@ -1,12 +1,12 @@
import { join } from 'node:path'; import { join } from 'node:path';
import { S3Client } from '@bradenmacdonald/s3-lite-client'; import { S3Client } from '@bradenmacdonald/s3-lite-client';
import { NUploader } from '@nostrify/nostrify';
import { crypto } from '@std/crypto'; import { crypto } from '@std/crypto';
import { encodeHex } from '@std/encoding/hex'; import { encodeHex } from '@std/encoding/hex';
import { extensionsByType } from '@std/media-types'; import { extensionsByType } from '@std/media-types';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { DittoUploader } from '@/interfaces/DittoUploader.ts';
export interface S3UploaderOpts { export interface S3UploaderOpts {
endPoint: string; endPoint: string;
@ -21,7 +21,7 @@ export interface S3UploaderOpts {
} }
/** S3-compatible uploader for AWS, Wasabi, DigitalOcean Spaces, and more. */ /** S3-compatible uploader for AWS, Wasabi, DigitalOcean Spaces, and more. */
export class S3Uploader implements DittoUploader { export class S3Uploader implements NUploader {
private client: S3Client; private client: S3Client;
constructor(opts: S3UploaderOpts) { constructor(opts: S3UploaderOpts) {