1.0.4 • Published 5 months ago

@w72/coco v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

coco

koa & fastify alternative

import { App, Router } from "@w72/coco";
import { z } from "zod";

const app = new App();

const router = new Router();

router.get(
  "/",
  {
    query: z.object({ test: z.optional(z.string()) }),
  },
  (ctx) => ({ hello: `hello ${ctx.query.test}` })
);

router.get(
  "/test/:id",
  {
    query: z.object({ test: z.optional(z.string()) }),
    params: z.object({ id: z.coerce.number() }),
  },
  (ctx) => ({ hello: `hello ${ctx.params.id} ${ctx.query.test}` })
);

app.use(router.middleware());
app.listen(8080);
app.log.info("Server starting at http://localhost:8080");
1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago