add redis db instead of sqlite

This commit is contained in:
ld3zian 2025-01-25 20:49:18 -07:00
parent 806f6dc07b
commit f3c566b3ad
5 changed files with 143 additions and 398 deletions

View file

@ -17,8 +17,8 @@ export const POST: APIRoute = async ({ request }) => {
const dataString = `${slugs.sort().join(',')}:${lang}`;
const hash = createHash('md5').update(dataString).digest('hex').slice(0, 8);
// Store the mapping in the database
storeFeedMapping(hash, slugs, lang);
// Store the mapping in Vercel KV
await storeFeedMapping(hash, slugs, lang);
return new Response(JSON.stringify({ feedId: hash }), {
status: 200,
@ -27,7 +27,8 @@ export const POST: APIRoute = async ({ request }) => {
}
});
} catch (error) {
return new Response("Invalid request", { status: 400 });
console.error('Error creating feed:', error);
return new Response("Internal server error", { status: 500 });
}
};

View file

@ -10,7 +10,7 @@ export const GET: APIRoute = async ({ params }) => {
return new Response("Feed ID not provided", { status: 400 });
}
const mapping = getFeedMapping(feedId);
const mapping = await getFeedMapping(feedId);
if (!mapping) {
return new Response("Feed not found", { status: 404 });