Add a basic news view page.

This commit is contained in:
yuanhau 2025-05-25 00:13:49 +08:00
parent 4b7934552c
commit f34da9f5c1
9 changed files with 90 additions and 25 deletions

View file

@ -4,9 +4,9 @@ import sql from "~/server/components/postgres";
const groq = new Groq();
export default defineEventHandler(async (event) => {
const host = getRequestHost(event);
const protocol = getRequestProtocol(event);
const hears = getRequestHeaders(event);
const host = getRequestHost(event);
const protocol = getRequestProtocol(event);
const hears = getRequestHeaders(event);
const slug = getRouterParam(event, "slug");
const body = await readBody(event);
if (!slug) {

View file

@ -4,8 +4,8 @@ import sql from "~/server/components/postgres";
const groq = new Groq();
export default defineEventHandler(async (event) => {
const host = getRequestHost(event);
const protocol = getRequestProtocol(event);
const host = getRequestHost(event);
const protocol = getRequestProtocol(event);
const slug = getRouterParam(event, "slug");
const buildURL = protocol + "://" + host + "/api/news/get/lt/" + slug;
const data = await fetch(buildURL);
@ -29,7 +29,7 @@ export default defineEventHandler(async (event) => {
stop: null,
});
const stream = new ReadableStream({
const stream = new ReadableStream({
async start(controller) {
try {
for await (const chunk of chatCompletion) {
@ -46,5 +46,4 @@ export default defineEventHandler(async (event) => {
},
});
return sendStream(event, stream);
});

View file

@ -0,0 +1,3 @@
export default defineEventHandler(async (event) => {
return "cool";
});