Skip to content

Instantly share code, notes, and snippets.

@jonathanhudak
Created May 6, 2022 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanhudak/edfcc1341333962b49507662e748b31d to your computer and use it in GitHub Desktop.
Save jonathanhudak/edfcc1341333962b49507662e748b31d to your computer and use it in GitHub Desktop.
mini-playroom-idea
import lzString from "https://esm.sh/lz-string";
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const router = new Router();
router
.get("/", (ctx) => {
ctx.response.body = "Hello world!";
})
.post("/save", async (ctx) => {
const result = ctx.request.body({ type: "text" });
const text = await result.value;
console.log(text);
ctx.response.body = lzString.compressToBase64(text);
})
.get("/component/:hash", async (ctx) => {
const hash = ctx?.params?.hash;
console.log("hash", hash);
ctx.response.body = lzString.decompressFromBase64(hash);
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
await app.listen({ port: 8000 });
@jonathanhudak
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment