Skip to content

Instantly share code, notes, and snippets.

@MagicDippyEgg
MagicDippyEgg / worker.ts
Last active August 13, 2026 05:19
deno bash
// @ts-nocheck — plain JS port, types omitted for faithfulness.
// Open the built-in Deno KV store
const kv = await Deno.openKv();
// A lightweight wrapper to make Deno KV act exactly like Cloudflare KV
// so we don't have to rewrite the entire bash simulation logic.
const store = {
async get(key) {
const entry = await kv.get([key]);
return entry.value ?? null;
@MagicDippyEgg
MagicDippyEgg / worker.js
Last active August 13, 2026 05:19
cloudflare bash
export default {
async fetch(request, env, ctx) {
// 1. Handle CORS Options Pre-flight for AI Clients
if (request.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
},