From 4c78f3f83e001a6787c3098bcd6f8d3e2787e769 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Tue, 22 Oct 2024 21:36:38 -0400 Subject: [PATCH] Add the post service to the middleware definition of the feed app, plan out how to get the feed. Cache the results. --- src/handlers/feed.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/handlers/feed.ts b/src/handlers/feed.ts index 807725c..e411cff 100644 --- a/src/handlers/feed.ts +++ b/src/handlers/feed.ts @@ -1,15 +1,19 @@ import { Hono, Context } from 'hono'; +import { PostService } from '@blog/services/post-file'; import { Feed } from 'feed'; -const feed = new Hono(); +const feed = new Hono<{ Variables: { postService: PostService }}>(); let feedBuffer: string = ""; export async function getFeedFile(c: Context) { c.header('Content-Type', 'text/xml'); if (!feedBuffer) { - // get the post meta + const postService: PostService = c.get('postService'); + const posts = postService.getPublishedPosts(); + // get the site meta + // create the feed // get the feed data feedBuffer = "";