0.9.0 • Published 1 month ago

velocirouter-js v0.9.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

🦕 VelociRouter

A minimal async RequestResponse router powered by URL Pattern API magic ✨

Documentation

Usage

Add dependency from JSR: @ssr/velocirouter

const router = new Router();

router.use(({request}) => {
  console.log(`[${request.method}] ${request.url}`);
});

Native JavaScript URL Pattern matching for routes.

router.get({pathname: '/api/hello/:name'}, ({match}) => {
  const {name} = match.pathname.groups;
  return new Response(`Hello ${name}!`);
});

Request & Response are forwarded through all matching routes in order.

router.all('/api/*', ({response}) => {
  if (response) {
    response.headers.set('x-api-version', '1');
  }
  return response;
});

Documentation

VelociRouter Documentation

Notes

Only Deno and Chromium based browsers have URL Pattern API support right now. Other runtimes like Bun and Node require a polyfill.

Inspired by Polka and Hono.


MIT License | Copyright © 2024 David Bushell

0.9.0

1 month ago

0.8.0

2 months ago

0.7.6

2 months ago

0.7.5

2 months ago

0.7.3

3 months ago

0.7.2

3 months ago

0.7.1

3 months ago

0.7.0

3 months ago

0.6.1

3 months ago

0.5.4

4 months ago

0.5.3

4 months ago

0.5.2

4 months ago

0.5.1

5 months ago

0.5.0

6 months ago

0.4.0

6 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.3.2

6 months ago