deno.land / x / abc@v1.3.3 / examples / cat_app / handler.ts
12345678910111213141516171819import type { HandlerFunc } from "../../mod.ts";import { CatDTO } from "./cat.ts";
import { Cat } from "./cat.ts";
const cats: Cat[] = [];
export const findAll: HandlerFunc = () => cats;export const findOne: HandlerFunc = (c) => { const { id } = c.params as { id: string }; return cats.find((cat) => cat.id.toString() === id);};export const create: HandlerFunc = async (c) => { const { name, age } = await c.body as CatDTO; const cat = new Cat({ name, age }); cats.push(cat); return cat;};
Version Info