mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 21:14:23 +00:00
Made the api page & mde the login page store the tokens.
This commit is contained in:
parent
41e12eb42b
commit
f1f47eb4a8
3 changed files with 49 additions and 18 deletions
|
@ -96,6 +96,8 @@ Use this form: <a href="https://yhw.tw/SaBta">https://yhw.tw/SaBta</a>
|
||||||
在 LINE 自己的口中 「LINE TODAY是消費者獲取各式知識資訊的重要入⼝」,當然可以讓新聞媒體給他新聞賺錢,所以很多Article多會在 LINE Today 上
|
在 LINE 自己的口中 「LINE TODAY是消費者獲取各式知識資訊的重要入⼝」,當然可以讓新聞媒體給他新聞賺錢,所以很多Article多會在 LINE Today 上
|
||||||
|
|
||||||
## FREE APIs:
|
## FREE APIs:
|
||||||
|
API Info: https://news.yuanhau.com/apis
|
||||||
|
|
||||||
If you just want to throw to an LLM and tell it to do stuff, here is the endpoints (w/cors, but I (hpware) has given permission for you to use it for free.), you are welcome to build something better than mine. Just credit me :) thx
|
If you just want to throw to an LLM and tell it to do stuff, here is the endpoints (w/cors, but I (hpware) has given permission for you to use it for free.), you are welcome to build something better than mine. Just credit me :) thx
|
||||||
|
|
||||||
https://news.yuanhau.com/api/tabs for fetching Tabs
|
https://news.yuanhau.com/api/tabs for fetching Tabs
|
||||||
|
|
|
@ -1,55 +1,88 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ArrowBigRightDashIcon, BadgeCheckIcon, BadgeXIcon, PanelTopIcon, RssIcon, NewspaperIcon, BotMessageSquareIcon, CombineIcon } from "lucide-vue-next";
|
||||||
const apis = [
|
const apis = [
|
||||||
{
|
{
|
||||||
|
icon: ArrowBigRightDashIcon,
|
||||||
apiroute: "/shortforward",
|
apiroute: "/shortforward",
|
||||||
name: "A Simple url forwarder.",
|
name: "A Simple url forwarder.",
|
||||||
content:
|
content:
|
||||||
"This is maly used for yhw.tw/news, which is a super simple redirection tool for easy redirecting.",
|
"This is maly used for yhw.tw/news, which is a super simple redirection tool for easy redirecting.",
|
||||||
caching: false,
|
caching: false,
|
||||||
|
openAccess: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
icon: PanelTopIcon,
|
||||||
apiroute: "/api/tabs",
|
apiroute: "/api/tabs",
|
||||||
name: "Get LINE Today Tabs",
|
name: "Get LINE Today Tabs",
|
||||||
content: "Using LINE Today as a source for getting tabs & caching results.",
|
content: "Using LINE Today as a source for getting tabs & caching results.",
|
||||||
caching: true,
|
caching: true,
|
||||||
|
openAccess: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
icon:RssIcon,
|
||||||
apiroute: "/api/home/lt",
|
apiroute: "/api/home/lt",
|
||||||
name: "Get the news feed of LINE Today",
|
name: "Get the news feed of LT",
|
||||||
content:
|
content:
|
||||||
"This endpoint requires ?query=, and you can go the the /api/tabs to find the query.",
|
"This endpoint requires ?query=, and you can go the the /api/tabs to find the query.",
|
||||||
caching: true,
|
caching: true,
|
||||||
|
openAccess: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
icon: NewspaperIcon,
|
||||||
apiroute: "/api/news/get/lt/[slug]",
|
apiroute: "/api/news/get/lt/[slug]",
|
||||||
name: "Get the news article using node-fetch & cheerio",
|
name: "Get the news article from LT",
|
||||||
content:
|
content:
|
||||||
"This endpoint requires the slug to be filled in, in order to get it to work.",
|
"This endpoint requires the slug to be filled in, in order to get it to work.",
|
||||||
caching: true,
|
caching: true,
|
||||||
|
openAccess: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
icon: BotMessageSquareIcon,
|
||||||
apiroute: "/api/ai/chat/[slug]",
|
apiroute: "/api/ai/chat/[slug]",
|
||||||
name: "",
|
name: "A Chating API",
|
||||||
content: "",
|
content: "This is for the desktop app & talk about news articles. Using Groq's free tier.",
|
||||||
caching: false,
|
caching: false,
|
||||||
|
openAccess: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
icon: CombineIcon,
|
||||||
apiroute: "/api/ai/summarize/[slug]",
|
apiroute: "/api/ai/summarize/[slug]",
|
||||||
name: "",
|
name: "A News Summarize using AI",
|
||||||
content: "",
|
content: "This is also powered by the Groq API (the free tier of course).",
|
||||||
caching: false,
|
caching: false,
|
||||||
|
openAccess: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
<div class="h-4"></div>
|
||||||
<div
|
<div
|
||||||
class="justify-center align-center text-center absolute inset-0 flex flex-col"
|
class="justify-center align-center text-center flex flex-col"
|
||||||
>
|
>
|
||||||
<h1 class="text-4xl text-bold">APIs</h1>
|
<h1 class="text-4xl text-bold m-2">APIs</h1>
|
||||||
<div class="items flex flex-row flex-wrap">
|
<div class="items flex flex-row flex-wrap gap-2 justify-center align-center">
|
||||||
<div class="item group" v-for="item in apis">
|
<div
|
||||||
{{ item.name }}
|
class="px-10 bg-gray-900/70 w-[400px] h-[300px] group rounded-xl hover:-translate-y-1 shadow-lg hover:shadow-sky-600/90 backdrop-blur-sm border border-gray-800 hover:border-sky-600/70 transition-all duration-700 justify-center align-middle flex flex-col text-left"
|
||||||
|
v-for="item in apis">
|
||||||
|
<component
|
||||||
|
:is="item.icon"
|
||||||
|
class="w-8 h-8 text-white group-hover:text-sky-500 transition-colors duration-300"
|
||||||
|
/>
|
||||||
|
<h1 class="text-2xl text-bold">{{ item.name || "N/A" }}</h1>
|
||||||
|
<h2>API: {{ item.apiroute }}</h2>
|
||||||
|
<p class="text-sm">{{ item.content || "N/A" }}</p>
|
||||||
|
<div class="gap-0 m-1">
|
||||||
|
<div class="text-md flex flex-row gap-2 text-center p-2">Caching:
|
||||||
|
<BadgeCheckIcon v-if="item.caching" class="w-7 h-7 p-1 group-hover:text-green-300 transition-all duration-200"/>
|
||||||
|
<BadgeXIcon v-else class="w-7 h-7 p-1 group-hover:text-red-400 transition-all duration-200"/>
|
||||||
|
</div>
|
||||||
|
<div class="text-md flex flex-row gap-2 text-center p-2">Open Access:
|
||||||
|
<BadgeCheckIcon v-if="item.caching" class="w-7 h-7 p-1 group-hover:text-green-300 transition-all duration-200"/>
|
||||||
|
<BadgeXIcon v-else class="w-7 h-7 p-1 group-hover:text-red-400 transition-all duration-200"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="h-4"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -25,8 +25,6 @@ export default defineEventHandler(async (event) => {
|
||||||
error: "INVALD_USER_ACCOUNT",
|
error: "INVALD_USER_ACCOUNT",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Server side hashing
|
|
||||||
|
|
||||||
// Check if user exists, if not, create a user
|
// Check if user exists, if not, create a user
|
||||||
try {
|
try {
|
||||||
console.log(username);
|
console.log(username);
|
||||||
|
@ -47,7 +45,6 @@ export default defineEventHandler(async (event) => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const newToken = uuidv4();
|
const newToken = uuidv4();
|
||||||
//const newToken64 = atob(newToken);
|
|
||||||
return {
|
return {
|
||||||
user: fetchUserInfo,
|
user: fetchUserInfo,
|
||||||
token: newToken,
|
token: newToken,
|
||||||
|
@ -64,14 +61,13 @@ export default defineEventHandler(async (event) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const newToken = uuidv4();
|
const newToken = uuidv4();
|
||||||
const newToken64 = btoa(newToken);
|
|
||||||
const fetchUserInfoAgain = await sql`
|
const fetchUserInfoAgain = await sql`
|
||||||
select * from users
|
select * from users
|
||||||
where username = ${username}`;
|
where username = ${username}`;
|
||||||
/*await sql`
|
await sql`
|
||||||
INSERT INTO usertokens (user, token)
|
INSERT INTO usertokens (user, token)
|
||||||
VALUES (${fetchUserInfo[0].username}, ${newToken64})
|
VALUES ('${fetchUserInfo[0].username}', '${newToken}')
|
||||||
`;*/
|
`;
|
||||||
return {
|
return {
|
||||||
user: fetchUserInfoAgain,
|
user: fetchUserInfoAgain,
|
||||||
token: newToken,
|
token: newToken,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue