dinatra
#Deno
https://github.com/syumai/dinatra
Sinatra
ライクな
Deno
のWebアプリケーションフレームワーク
code:typescript
import {
app,
get,
post
} from "
https://denopkg.com/syumai/dinatra@0.9.0/mod.ts";
app(
get("/posts/:id", async (ctx) => {
const post = await findPostByID(ctx.params.id);
return post ?
200, JSON.stringify(post)
:
404, ""
;
}),
post("/posts", async (ctx) => {
const post = await addPost(ctx.params);
return
201, contentType("json"), String(post.id)
;
}),
);