Newest
1
2
3
4
5
6
7
export const honoExample = async (req: Request) => {
const { Hono } = await import("npm:hono@3");
const app = new Hono();
app.get("/", (c) => c.text("Hono?"));
app.get("/yeah", (c) => c.text("Routing!"));
return app.fetch(req);
};
1
2
3
4
5
6
7
8
9
10
async function hexToUtf8(hex) {
if (hex.startsWith("0x")) {
hex = hex.slice(2);
}
let str = "";
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return decodeURIComponent(escape(str));
}
1
2
3
4
let tursoExample = me.turso().execute({
sql: `select value from kv where key=?`,
args: ["hello"],
});
Allows Observable notebooks to statically import ES modules as Runtime modules.
See https://observablehq.com/d/1ff60814f0002dd5 for details and examples.
Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const observable_esm = async (request: Request): Promise<Response> => {
const url = new URL(request.url);
url.protocol = "https";
url.hostname = "esm.sh";
const body = `
import * as module from ${JSON.stringify(url)};
export default function define(runtime, observer) {
const main = runtime.module();
main.variable(observer("__module")).define("__module", () => module);
for(const key of Object.keys(module)) {
const alias = key === "default" ? "__" + key : key;
main.variable(observer(alias)).define(alias, () => module[key]);
}
return main;
}
`;
// Increase caching duration if we have a version specifier.
const maxAge = 60 * 60 * (url.pathname.slice(2).includes("@") ? 24 : 1);
return new Response(body, {
headers: {
"Content-Type": "application/javascript",
"Cache-Control": `public, max-age=${maxAge}`,
},
});
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export const warden = () => {
const whatHeDoinUnderThere = IronFlare.randomPhrase([
"got hemorrhoids",
"playing a rhythm game",
"carrying a League of Legends game, about to close it out, when his bra-less wife brings him a sandwich (not asked for) with chips as he gets a kill bot lane",
"got an itchy leg",
"listening to music",
"whipping some heavy cream",
]);
if (Math.random() > 0.98) {
return `He’s masturbating.`;
}
return `It’s not what it looks like! He’s just ${whatHeDoinUnderThere}!`;
};