Offload tagging to api
This commit is contained in:
parent
d4b51f9803
commit
a9ce012ccb
@ -1,13 +1,4 @@
|
|||||||
|
|
||||||
interface Env {
|
interface Env {
|
||||||
KV: KVNamespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RawEvent {
|
|
||||||
id: string,
|
|
||||||
content: string,
|
|
||||||
created_at: string,
|
|
||||||
pubkey: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const onRequest: PagesFunction<Env> = async (context) => {
|
export const onRequest: PagesFunction<Env> = async (context) => {
|
||||||
@ -17,12 +8,18 @@ export const onRequest: PagesFunction<Env> = async (context) => {
|
|||||||
console.debug(next.status);
|
console.debug(next.status);
|
||||||
console.debug("Fetching data for: ", id);
|
console.debug("Fetching data for: ", id);
|
||||||
|
|
||||||
const rsp = await fetch(`https://api.snort.social/api/v1/raw/e/${id}`);
|
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/e/${id}`, {
|
||||||
|
method: "POST",
|
||||||
|
body: await next.arrayBuffer(),
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/plain"
|
||||||
|
}
|
||||||
|
});
|
||||||
console.debug(rsp.status, rsp.statusText);
|
console.debug(rsp.status, rsp.statusText);
|
||||||
if (rsp.ok) {
|
const body = await rsp.text();
|
||||||
const json: RawEvent = await rsp.json();
|
return new Response(body, {
|
||||||
console.debug(json);
|
headers: {
|
||||||
|
"content-type": "text/html"
|
||||||
}
|
}
|
||||||
return new Response("test");
|
});
|
||||||
}
|
}
|
25
functions/p/[id].ts
Normal file
25
functions/p/[id].ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
interface Env {
|
||||||
|
}
|
||||||
|
|
||||||
|
export const onRequest: PagesFunction<Env> = async (context) => {
|
||||||
|
const id = context.params.id as string;
|
||||||
|
|
||||||
|
const next = await context.next();
|
||||||
|
console.debug(next.status);
|
||||||
|
console.debug("Fetching data for: ", id);
|
||||||
|
|
||||||
|
const rsp = await fetch(`https://api.snort.social/api/v1/og/tag/p/${id}`, {
|
||||||
|
method: "POST",
|
||||||
|
body: await next.arrayBuffer(),
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/plain"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.debug(rsp.status, rsp.statusText);
|
||||||
|
const body = await rsp.text();
|
||||||
|
return new Response(body, {
|
||||||
|
headers: {
|
||||||
|
"content-type": "text/html"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user