Skip to content

momo1037/coco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");

About

Koa & fastify alternative

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published