From c1bf326981f0d3ff39305e3793a1f7238e798ab0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 20 Nov 2023 12:39:20 -0600 Subject: [PATCH] c.req.headers.get --> c.req.header, hono deprecation --- src/controllers/api/streaming.ts | 4 ++-- src/controllers/nostr/relay.ts | 2 +- src/middleware/auth19.ts | 2 +- src/sign.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 6a9e535b..d7aa6773 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -28,8 +28,8 @@ const streamSchema = z.enum([ type Stream = z.infer; const streamingController: AppController = (c) => { - const upgrade = c.req.headers.get('upgrade'); - const token = c.req.headers.get('sec-websocket-protocol'); + const upgrade = c.req.header('upgrade'); + const token = c.req.header('sec-websocket-protocol'); const stream = streamSchema.optional().catch(undefined).parse(c.req.query('stream')); if (upgrade?.toLowerCase() !== 'websocket') { diff --git a/src/controllers/nostr/relay.ts b/src/controllers/nostr/relay.ts index 3a5a9aa5..9f5cd596 100644 --- a/src/controllers/nostr/relay.ts +++ b/src/controllers/nostr/relay.ts @@ -117,7 +117,7 @@ function prepareFilters(filters: ClientREQ[2][]): Filter[] { } const relayController: AppController = (c) => { - const upgrade = c.req.headers.get('upgrade'); + const upgrade = c.req.header('upgrade'); if (upgrade?.toLowerCase() !== 'websocket') { return c.text('Please use a Nostr client to connect.', 400); diff --git a/src/middleware/auth19.ts b/src/middleware/auth19.ts index fec79ad0..19344fbd 100644 --- a/src/middleware/auth19.ts +++ b/src/middleware/auth19.ts @@ -6,7 +6,7 @@ const BEARER_REGEX = new RegExp(`^Bearer (${nip19.BECH32_REGEX.source})$`); /** NIP-19 auth middleware. */ const auth19: AppMiddleware = async (c, next) => { - const authHeader = c.req.headers.get('authorization'); + const authHeader = c.req.header('authorization'); const match = authHeader?.match(BEARER_REGEX); if (match) { diff --git a/src/sign.ts b/src/sign.ts index b5bbd339..0662668d 100644 --- a/src/sign.ts +++ b/src/sign.ts @@ -25,7 +25,7 @@ async function signEvent( opts: SignEventOpts = {}, ): Promise> { const seckey = c.get('seckey'); - const header = c.req.headers.get('x-nostr-sign'); + const header = c.req.header('x-nostr-sign'); if (seckey) { return finishEvent(event, seckey);