mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 07:41:02 +08:00
12 lines
381 B
TypeScript
12 lines
381 B
TypeScript
import sql from "~/server/components/postgres";
|
|
export default defineEventHandler(async (event) => {
|
|
const articles = await sql`
|
|
SELECT * FROM news_articles;
|
|
`;
|
|
setHeaders(event, {
|
|
"Content-Type": "application/json",
|
|
"Content-Disposition": `attachment; filename="news-articles-export-${new Date().toISOString().split("T")[0]}.json"`,
|
|
});
|
|
return articles;
|
|
});
|