Add support for Blossom uploader
This commit is contained in:
parent
7c5b7c5d83
commit
f0b247130f
|
@ -140,6 +140,10 @@ class Conf {
|
|||
static get nostrbuildEndpoint(): string {
|
||||
return Deno.env.get('NOSTRBUILD_ENDPOINT') || 'https://nostr.build/api/v2/upload/files';
|
||||
}
|
||||
/** Default Blossom servers to use when the `blossom` uploader is set. */
|
||||
static get blossomServers(): string[] {
|
||||
return Deno.env.get('BLOSSOM_SERVERS')?.split(',') || ['https://blossom.primal.net/'];
|
||||
}
|
||||
/** Module to upload files with. */
|
||||
static get uploader() {
|
||||
return Deno.env.get('DITTO_UPLOADER');
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { BlossomUploader } from '@nostrify/nostrify/uploaders';
|
||||
|
||||
import { AppMiddleware } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { DenoUploader } from '@/uploaders/DenoUploader.ts';
|
||||
|
@ -8,6 +10,8 @@ import { fetchWorker } from '@/workers/fetch.ts';
|
|||
|
||||
/** Set an uploader for the user. */
|
||||
export const uploaderMiddleware: AppMiddleware = async (c, next) => {
|
||||
const signer = c.get('signer');
|
||||
|
||||
switch (Conf.uploader) {
|
||||
case 's3':
|
||||
c.set('uploader', new S3Uploader(Conf.s3));
|
||||
|
@ -21,6 +25,11 @@ export const uploaderMiddleware: AppMiddleware = async (c, next) => {
|
|||
case 'nostrbuild':
|
||||
c.set('uploader', new NostrBuildUploader({ endpoint: Conf.nostrbuildEndpoint, fetch: fetchWorker }));
|
||||
break;
|
||||
case 'blossom':
|
||||
if (signer) {
|
||||
c.set('uploader', new BlossomUploader({ servers: Conf.blossomServers, signer, fetch: fetchWorker }));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await next();
|
||||
|
|
Loading…
Reference in New Issue