Add the post service to the middleware definition of the feed app, plan out how to get the feed. Cache the results.

This commit is contained in:
Dave Smith-Hayes 2024-10-22 21:36:38 -04:00
parent e21de55d3f
commit 4c78f3f83e

View File

@ -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 = "";