Files
InfoFlow/bak/server.js

30 lines
858 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// server.js
import { serve } from "bun";
import { fetchRSS } from "./rss.js";
import { analyzeContent } from "./ai.js";
import { getWeChatArticleLinks } from "./wechat.js";
const PORT = 3000;
async function handleRequest(request) {
// 从环境变量中获取 RSS URL如果没有则使用默认值
const rssUrl = "https://mp.weixin.qq.com/s/vQgsMuxXffpFZkNFj89wUQ";
try {
const rssContent = await fetchRSS(rssUrl);
const analyzedContent = await analyzeContent(rssContent);
return new Response(analyzedContent, {
headers: { "Content-Type": "text/markdown" },
});
} catch (error) {
console.error("Error processing request:", error);
return new Response("Error processing request", { status: 500 });
}
}
serve({
port: PORT,
fetch: handleRequest,
});
console.log(`Server running at http://localhost:${PORT}`);