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 { 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 */

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 { 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;

View File

@ -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;

View File

@ -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) {