mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 13:04:23 +00:00
Ok? It maybe works?
This commit is contained in:
parent
bb7ab3a088
commit
a0c4d2317e
3 changed files with 9 additions and 9 deletions
|
@ -5,7 +5,7 @@ This took me some time, but they use a fancy system for pulling news data.
|
|||
## Endpoint on news.yuanhau.com aka this repo (Cached results)
|
||||
|
||||
|
||||
### /api/home/uuid_lt/feed?query=${query}
|
||||
### /api/home/lt?query=${query}
|
||||
Fetches the uuid and returns back with the news
|
||||
|
||||
## Main endpoint
|
||||
|
|
|
@ -19,7 +19,7 @@ export default defineNuxtConfig({
|
|||
},
|
||||
"/api/cached/**": { swr: 3600 },
|
||||
"/api/news/get": { swr: 3600 },
|
||||
"/api/home/uuid_lt": { swr: 3600 },
|
||||
"/api/home/lt": { swr: 3600 },
|
||||
},
|
||||
|
||||
css: ["~/styles/main.css"],
|
||||
|
|
|
@ -10,7 +10,10 @@ async function getUUID(orgtype: string) {
|
|||
const type = orgtype.toLowerCase();
|
||||
if (cache[type] && Date.now() - cache[type].timestamp < CACHE_DURATION) {
|
||||
console.log("Serving from cache for type:", type);
|
||||
return cache[type].data;
|
||||
return {
|
||||
...cache[type].data,
|
||||
cached: true,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -60,7 +63,7 @@ function filterUUIDs(ids: string[]): string[] {
|
|||
}
|
||||
|
||||
function filter2(ids: string[]): string[] {
|
||||
const pattern = /.*:[a-zA-Z0-9]{24}/g;
|
||||
const pattern = /news_cat:[a-zA-Z0-9]{24}/g;
|
||||
return ids.filter((id) => pattern.test(id));
|
||||
}
|
||||
|
||||
|
@ -113,11 +116,8 @@ export default defineEventHandler(async (event) => {
|
|||
const fillll = filter2(diffFormat);
|
||||
const cconaa: any[] = await Promise.all(
|
||||
fillll.map(async (key) => {
|
||||
if (key.includes("news_cat")) {
|
||||
const data = await tryToPullDataNUUID(key);
|
||||
return data;
|
||||
} else {
|
||||
}
|
||||
}),
|
||||
).then((ans) => ans.flat());
|
||||
return {
|
Loading…
Add table
Add a link
Reference in a new issue