From 0925f37929809cae9f8f064eaa63fb7785bdc43c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 29 Apr 2024 15:04:13 -0500 Subject: [PATCH] Make storeMiddleware available in every request --- src/app.ts | 8 ++++---- src/controllers/api/timelines.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app.ts b/src/app.ts index abdec32..7e74f6d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -91,7 +91,7 @@ interface AppEnv extends HonoEnv { /** User associated with the pubkey, if any. */ user?: User; /** Store */ - store?: NStore; + store: NStore; }; } @@ -119,7 +119,7 @@ app.get('/api/v1/streaming', streamingController); app.get('/api/v1/streaming/', streamingController); app.get('/relay', relayController); -app.use('*', csp(), cors({ origin: '*', exposeHeaders: ['link'] }), auth19, auth98()); +app.use('*', csp(), cors({ origin: '*', exposeHeaders: ['link'] }), auth19, auth98(), storeMiddleware); app.get('/.well-known/webfinger', webfingerController); app.get('/.well-known/host-meta', hostMetaController); @@ -173,8 +173,8 @@ app.delete('/api/v1/statuses/:id{[0-9a-f]{64}}', requirePubkey, deleteStatusCont app.post('/api/v1/media', mediaController); app.post('/api/v2/media', mediaController); -app.get('/api/v1/timelines/home', requirePubkey, storeMiddleware, homeTimelineController); -app.get('/api/v1/timelines/public', storeMiddleware, publicTimelineController); +app.get('/api/v1/timelines/home', requirePubkey, homeTimelineController); +app.get('/api/v1/timelines/public', publicTimelineController); app.get('/api/v1/timelines/tag/:hashtag', hashtagTimelineController); app.get('/api/v1/preferences', preferencesController); diff --git a/src/controllers/api/timelines.ts b/src/controllers/api/timelines.ts index 191fce7..40b54c9 100644 --- a/src/controllers/api/timelines.ts +++ b/src/controllers/api/timelines.ts @@ -1,4 +1,4 @@ -import { NostrFilter, NStore } from '@nostrify/nostrify'; +import { NostrFilter } from '@nostrify/nostrify'; import { z } from 'zod'; import { type AppContext, type AppController } from '@/app.ts'; @@ -45,7 +45,7 @@ const hashtagTimelineController: AppController = (c) => { /** Render statuses for timelines. */ async function renderStatuses(c: AppContext, filters: NostrFilter[]) { const { signal } = c.req.raw; - const store = c.get('store') as NStore; + const store = c.get('store'); const events = await store .query(filters, { signal })