mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 05:24:23 +00:00
Refactor API endpoints to use cached data and update Code of Conduct to Contributor Covenant
This commit is contained in:
parent
878ac4f1a6
commit
96b297f617
17 changed files with 207 additions and 31 deletions
13
server/api/cached/getData/fetchNewsOrgInfo.ts
Normal file
13
server/api/cached/getData/fetchNewsOrgInfo.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
return {
|
||||
body: body,
|
||||
title: "News Org 1",
|
||||
slug: "taisounds",
|
||||
website: "https://www.taisounds.com.tw",
|
||||
description: "wah wah wah wah wah wah I dont fucking care",
|
||||
facebook: "https://www.facebook.com/taisounds",
|
||||
logoUrl:
|
||||
"https://cdn.discordapp.com/avatars/918723093646684180/4eecc27ac05ee8a701fa167808610c7a.jpg",
|
||||
};
|
||||
});
|
13
server/api/cached/getData/fetchSidebarData.ts
Normal file
13
server/api/cached/getData/fetchSidebarData.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
return {
|
||||
0: {
|
||||
id: "1",
|
||||
image: "whatever",
|
||||
tags: [],
|
||||
title: "三立新聞",
|
||||
lean: "left",
|
||||
score: "40",
|
||||
},
|
||||
};
|
||||
});
|
27
server/api/cached/getData/fetchSources.ts
Normal file
27
server/api/cached/getData/fetchSources.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import sql from "~/server/components/postgres";
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
const query = getQuery(event);
|
||||
/*const sources = await sql`SELECT * FROM sources`;
|
||||
return sources;*/
|
||||
// Fake data
|
||||
return {
|
||||
status: "ok",
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Source 1",
|
||||
logo: "#",
|
||||
url: "https://source1.com",
|
||||
description: "Description for Source 1",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Source 2",
|
||||
logo: "#",
|
||||
url: "https://source2.com",
|
||||
description: "Description for Source 2",
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue