Add NIP-11 support

This commit is contained in:
Alex Gleason
2023-12-19 21:15:41 -06:00
parent b9e756de26
commit 26e64e781c
3 changed files with 28 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
import * as eventsDB from '@/db/events.ts';
import * as pipeline from '@/pipeline.ts';
import { jsonSchema } from '@/schema.ts';
@@ -116,9 +117,14 @@ function prepareFilters(filters: ClientREQ[2][]): Filter[] {
}));
}
const relayController: AppController = (c) => {
const relayController: AppController = (c, next) => {
const upgrade = c.req.header('upgrade');
// NIP-11: https://github.com/nostr-protocol/nips/blob/master/11.md
if (c.req.header('accept') === 'application/nostr+json') {
return relayInfoController(c, next);
}
if (upgrade?.toLowerCase() !== 'websocket') {
return c.text('Please use a Nostr client to connect.', 400);
}