Created
May 6, 2022 15:44
-
-
Save jonathanhudak/edfcc1341333962b49507662e748b31d to your computer and use it in GitHub Desktop.
mini-playroom-idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://dash.deno.com/playground/thick-robin-60