From a574a5b8177ca985ef13f3b3e93acf92d26e6b13 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Wed, 1 Apr 2026 13:24:22 -0400 Subject: [PATCH] fix(extensions): add HTTP route types and getHttpRoutes to Extension interface HttpRoute, HttpRequest, and HttpResponse types were used by extensions (withdraw, nip05) but not defined in the shared types.ts. Adds them here so extensions import from the shared module instead of defining locally. Also adds getHttpRoutes() as an optional method on the Extension interface for extensions that expose HTTP endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/extensions/types.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/extensions/types.ts b/src/extensions/types.ts index 62abf5df..2027fb09 100644 --- a/src/extensions/types.ts +++ b/src/extensions/types.ts @@ -191,6 +191,31 @@ export interface ExtensionContext { log(level: 'debug' | 'info' | 'warn' | 'error', message: string, ...args: any[]): void } +/** + * HTTP route handler types + * Used by extensions that expose HTTP endpoints (e.g. LNURL, .well-known) + */ +export interface HttpRequest { + method: string + path: string + params: Record + query: Record + headers: Record + body?: any +} + +export interface HttpResponse { + status: number + body: any + headers?: Record +} + +export interface HttpRoute { + method: 'GET' | 'POST' + path: string + handler: (req: HttpRequest) => Promise +} + /** * Extension interface - what extensions must implement */ @@ -217,6 +242,12 @@ export interface Extension { * Return true if extension is healthy */ healthCheck?(): Promise + + /** + * Get HTTP routes exposed by this extension + * The main HTTP server will mount these routes + */ + getHttpRoutes?(): HttpRoute[] } /**