5export const set = async (key: string, value = "") => {
6 if (!isValidKey(key)) throw new Error(`Invalid note.ms key`);
7 const res = await fetch(`https://note.ms/${key}`, {
8 headers: {
9 "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
18export const get = async (key: string) => {
19 if (!isValidKey(key)) throw new Error(`Invalid note.ms key`);
20 const res = await fetch(`https://note.ms/${key}`, { headers: { Referer: `https://note.ms/${key}` } });
21 if (!res.ok) throw new Error(res.statusText);
22 const matched = (await res.text()).match(/<textarea class="content">([\s\S]*?)<\/textarea>/);
2
3const gpt3Example = async () => {
4 const response = await fetch("https://api.openai.com/v1/completions", {
5 method: "POST",
6 headers: {
13
14 try {
15 const data = await fetch(
16 `https://www.googleapis.com/customsearch/v1?q=${searchKey}&cx=70c6ff0b41f6943a4&key=AIzaSyAY7rS9VJVEcS6196uOWXOx2mCq_cN2kXM&c2coff=1&start=1&num=5&dateRestrict=m%5B1%5D`,
17 )
22 }
23 });
24 return app.fetch;
25}
1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
25
26 const getSearch = async (data) => {
27 const response = await fetch("https://api.openai.com/v1/completions", {
28 method: "GET",
29 body: JSON.stringify(data),
22 return c.text("Added comment!", 200);
23});
24export default app.fetch;
22 return c.json({ message: "Comment added!" });
23});
24export default app.fetch;
11app.get("/edit/:blob", async (c) => c.html(`TODO: Edit ${c.req.param("blob")}`));
12app.get("/delete/:blob", async (c) => c.html(`TODO: Delete ${c.req.param("blob")}`));
13export default basicAuth(app.fetch);
7
8const getComments = async () => {
9 const response = await fetch(MY_FORKED_VAL_URL);
10 const json = await response.json();
11 return json;
14const addComment = async (str) => {
15 try {
16 const response = await fetch(MY_FORKED_VAL_URL, {
17 method: "POST",
18 body: JSON.stringify(str),
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2import process from "node:process";
3
4export const browserlessScrapeExample = (async () => {
5 const res = await fetchJSON(
6 `https://chrome.browserless.io/scrape?token=${process.env.browserlessKey}`,
7 {