deno.land / x / abc@v1.3.3 / examples / cat_app / handler.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import 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;};
abc

Version Info

Tagged at
3 years ago