mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Start implementing relay management API
This commit is contained in:
parent
6fe034d55a
commit
3c92bd36a2
4 changed files with 12 additions and 9 deletions
|
|
@ -159,7 +159,7 @@ app.use('/nodeinfo/*', metricsMiddleware, logger(debug));
|
|||
app.use('/oauth/*', metricsMiddleware, logger(debug));
|
||||
|
||||
app.get('/api/v1/streaming', metricsMiddleware, streamingController);
|
||||
app.get('/relay', metricsMiddleware, relayController);
|
||||
app.all('/relay', metricsMiddleware, relayController);
|
||||
|
||||
app.use(
|
||||
'*',
|
||||
|
|
|
|||
5
src/controllers/nostr/management.ts
Normal file
5
src/controllers/nostr/management.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { AppController } from '@/app.ts';
|
||||
|
||||
export const managementController: AppController = (c) => {
|
||||
return c.json({ error: 'Not found' }, 404);
|
||||
};
|
||||
|
|
@ -167,10 +167,13 @@ 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') {
|
||||
if (c.req.method === 'GET' && c.req.header('accept') === 'application/nostr+json') {
|
||||
return relayInfoController(c, next);
|
||||
}
|
||||
|
||||
// NIP-86: https://github.com/nostr-protocol/nips/pull/1325
|
||||
if (c.req.header('content-type') === 'application/nostr+json+rpc') {}
|
||||
|
||||
if (upgrade?.toLowerCase() !== 'websocket') {
|
||||
return c.text('Please use a Nostr client to connect.', 400);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,16 +2,11 @@ import { HTTPException } from '@hono/hono/http-exception';
|
|||
import { NostrEvent } from '@nostrify/nostrify';
|
||||
|
||||
import { type AppContext, type AppMiddleware } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { ReadOnlySigner } from '@/signers/ReadOnlySigner.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
import { localRequest } from '@/utils/api.ts';
|
||||
import {
|
||||
buildAuthEventTemplate,
|
||||
parseAuthRequest,
|
||||
type ParseAuthRequestOpts,
|
||||
validateAuthEvent,
|
||||
} from '@/utils/nip98.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { buildAuthEventTemplate, parseAuthRequest, ParseAuthRequestOpts, validateAuthEvent } from '@/utils/nip98.ts';
|
||||
|
||||
/**
|
||||
* NIP-98 auth.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue