-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
260 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 2 additions & 38 deletions
40
...src/interfaces/handle-result.interface.ts → ...src/interfaces/handle-result.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/common/src/interfaces/nostr-relay-options.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { LogLevel } from '../constants'; | ||
import { Logger } from './logger.interface'; | ||
|
||
/** | ||
* Options for NostrRelay | ||
*/ | ||
export type NostrRelayOptions = { | ||
/** | ||
* Domain name of the Nostr Relay server. If not set, NIP-42 is not enabled. | ||
* More info: https://github.com/nostr-protocol/nips/blob/master/42.md | ||
*/ | ||
domain?: string; | ||
/** | ||
* Logger to use. `Default: ConsoleLoggerService` | ||
*/ | ||
logger?: Logger; | ||
/** | ||
* The minimum log level to log. `Default: LogLevel.INFO` | ||
*/ | ||
logLevel?: LogLevel; | ||
createdAtUpperLimit?: number; | ||
createdAtLowerLimit?: number; | ||
/** | ||
* Allowed minimum PoW difficulty for events.` Default: 0` | ||
*/ | ||
minPowDifficulty?: number; | ||
/** | ||
* Maximum number of subscriptions per client. `Default: 20` | ||
*/ | ||
maxSubscriptionsPerClient?: number; | ||
/** | ||
* TTL for filter result cache in milliseconds. `Default: 1000` | ||
*/ | ||
filterResultCacheTtl?: number; | ||
/** | ||
* TTL for event handling result cache in milliseconds. `Default: 600000` | ||
*/ | ||
eventHandlingResultCacheTtl?: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,22 @@ | ||
import { ClientContext } from '../client-context'; | ||
import { Event, EventHandleResult } from './event.interface'; | ||
import { Event } from './event.interface'; | ||
import { HandleMessageResult } from './handle-result.interface'; | ||
import { IncomingMessage } from './message.interface'; | ||
|
||
export type NostrRelayPlugin = | ||
| BeforeEventHandle | ||
| AfterEventHandle | ||
| BeforeEventBroadcast | ||
| AfterEventBroadcast; | ||
export type NostrRelayPlugin = HandleMessageMiddleware | BroadcastMiddleware; | ||
|
||
export type BeforeHookResult<T = {}> = | ||
| { canContinue: true } | ||
| ({ canContinue: false } & T); | ||
|
||
export type BeforeEventHandleResult = BeforeHookResult<{ | ||
result: EventHandleResult; | ||
}>; | ||
|
||
export interface BeforeEventHandle { | ||
beforeEventHandle( | ||
export interface HandleMessageMiddleware { | ||
handleMessage( | ||
ctx: ClientContext, | ||
event: Event, | ||
): Promise<BeforeEventHandleResult> | BeforeEventHandleResult; | ||
message: IncomingMessage, | ||
next: () => Promise<HandleMessageResult>, | ||
): Promise<HandleMessageResult> | HandleMessageResult; | ||
} | ||
|
||
export interface AfterEventHandle { | ||
afterEventHandle( | ||
export interface BroadcastMiddleware { | ||
broadcast( | ||
ctx: ClientContext, | ||
event: Event, | ||
handleResult: EventHandleResult, | ||
next: () => Promise<void>, | ||
): Promise<void> | void; | ||
} | ||
|
||
export interface BeforeEventBroadcast { | ||
beforeEventBroadcast( | ||
ctx: ClientContext, | ||
event: Event, | ||
): Promise<BeforeHookResult> | BeforeHookResult; | ||
} | ||
|
||
export interface AfterEventBroadcast { | ||
afterEventBroadcast(ctx: ClientContext, event: Event): Promise<void> | void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.