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)
|
## 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
|
Fetches the uuid and returns back with the news
|
||||||
|
|
||||||
## Main endpoint
|
## Main endpoint
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default defineNuxtConfig({
|
||||||
},
|
},
|
||||||
"/api/cached/**": { swr: 3600 },
|
"/api/cached/**": { swr: 3600 },
|
||||||
"/api/news/get": { swr: 3600 },
|
"/api/news/get": { swr: 3600 },
|
||||||
"/api/home/uuid_lt": { swr: 3600 },
|
"/api/home/lt": { swr: 3600 },
|
||||||
},
|
},
|
||||||
|
|
||||||
css: ["~/styles/main.css"],
|
css: ["~/styles/main.css"],
|
||||||
|
|
|
@ -10,7 +10,10 @@ async function getUUID(orgtype: string) {
|
||||||
const type = orgtype.toLowerCase();
|
const type = orgtype.toLowerCase();
|
||||||
if (cache[type] && Date.now() - cache[type].timestamp < CACHE_DURATION) {
|
if (cache[type] && Date.now() - cache[type].timestamp < CACHE_DURATION) {
|
||||||
console.log("Serving from cache for type:", type);
|
console.log("Serving from cache for type:", type);
|
||||||
return cache[type].data;
|
return {
|
||||||
|
...cache[type].data,
|
||||||
|
cached: true,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -60,7 +63,7 @@ function filterUUIDs(ids: string[]): string[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter2(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));
|
return ids.filter((id) => pattern.test(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,11 +116,8 @@ export default defineEventHandler(async (event) => {
|
||||||
const fillll = filter2(diffFormat);
|
const fillll = filter2(diffFormat);
|
||||||
const cconaa: any[] = await Promise.all(
|
const cconaa: any[] = await Promise.all(
|
||||||
fillll.map(async (key) => {
|
fillll.map(async (key) => {
|
||||||
if (key.includes("news_cat")) {
|
|
||||||
const data = await tryToPullDataNUUID(key);
|
const data = await tryToPullDataNUUID(key);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
).then((ans) => ans.flat());
|
).then((ans) => ans.flat());
|
||||||
return {
|
return {
|
Loading…
Add table
Add a link
Reference in a new issue