mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 07:41:02 +08:00
Add archiving system & pushing news org.
This commit is contained in:
parent
38ce057937
commit
61f56a8c0a
11
server/api/download/news-article-archive.json.ts
Normal file
11
server/api/download/news-article-archive.json.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
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;
|
||||||
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import sql from "~/server/components/postgres";
|
import sql from "~/server/components/postgres";
|
||||||
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
import CheckKidUnfriendlyContent from "~/components/checks/checkKidUnfriendlyContent";
|
||||||
import * as cheerio from "cheerio";
|
import * as cheerio from "cheerio";
|
||||||
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
// Caching
|
// Caching
|
||||||
|
|
||||||
@ -91,9 +92,16 @@ export default defineEventHandler(async (event) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*const pushNewsOrg = await sql`
|
const pushNewsOrg = await sql`
|
||||||
insert into
|
insert into lt_news_org (news_id, name, description)
|
||||||
`*/
|
values (${uuidv4()}, ${newsOrgName}, ${description})
|
||||||
|
`;
|
||||||
|
console.log(pushNewsOrg);
|
||||||
|
/**
|
||||||
|
* news_id text primary key,
|
||||||
|
name text not null,
|
||||||
|
description text
|
||||||
|
*/
|
||||||
cache[slug] = {
|
cache[slug] = {
|
||||||
slug: slug,
|
slug: slug,
|
||||||
title: newsOrgName,
|
title: newsOrgName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user