Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lukeshay/pongjs

A simple router for Cloudflare workers
https://github.com/lukeshay/pongjs

cloudflare cloudflare-workers router

Last synced: about 7 hours ago
JSON representation

A simple router for Cloudflare workers

Awesome Lists containing this project

README

        

# Cloudflare Worker Router

A simple router for Cloudflare workers.

```ts
import { router } from "@pongjs/router";

export interface Env {
DB: D1Database;
}

router.add("GET", "/hello/:name", async (request: Request, env: Env) => {
return Response.json({
message: `Hello, ${name}`,
});
});

export default router;
```

See [path-to-regex](https://www.npmjs.com/package/path-to-regex) for how the paths work.