diff --git a/functions/e/[id].ts b/functions/e/[id].ts new file mode 100644 index 00000000..58f0b518 --- /dev/null +++ b/functions/e/[id].ts @@ -0,0 +1,28 @@ + +interface Env { + KV: KVNamespace; +} + +interface RawEvent { + id: string, + content: string, + created_at: string, + pubkey: string +} + +export const onRequest: PagesFunction = 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/raw/e/${id}`); + console.debug(rsp.status, rsp.statusText); + if (rsp.ok) { + const json: RawEvent = await rsp.json(); + console.debug(json); + + } + return new Response("test"); +} \ No newline at end of file diff --git a/functions/tsconfig.json b/functions/tsconfig.json new file mode 100644 index 00000000..e0b6870e --- /dev/null +++ b/functions/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "lib": ["esnext"], + "types": ["@cloudflare/workers-types"] + } + } \ No newline at end of file diff --git a/package.json b/package.json index 0fe9faf5..8e2e17d5 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "start": "yarn workspace @snort/nostr build && yarn workspace @snort/app start" }, "devDependencies": { - "@tauri-apps/cli": "^1.2.3" + "@tauri-apps/cli": "^1.2.3", + "@cloudflare/workers-types": "^4.20230307.0" } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 1eaed49e..768014c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1083,6 +1083,11 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@cloudflare/workers-types@^4.20230307.0": + version "4.20230307.0" + resolved "https://registry.yarnpkg.com/@cloudflare/workers-types/-/workers-types-4.20230307.0.tgz#58a20fe167a5c48e20edba8e1fbfe4231bcfa223" + integrity sha512-Go968aDDcqONHQcUdgIiPRkPdT4QTzD0ecHJsI1u7ZiHPMOoZn+Dy7hYsdUJ5ldX9wTZDrICBM1rDKTRaDUitg== + "@csstools/normalize.css@*": version "12.0.0" resolved "https://registry.yarnpkg.com/@csstools/normalize.css/-/normalize.css-12.0.0.tgz#a9583a75c3f150667771f30b60d9f059473e62c4"