1.0.2 • Published 1 year ago

micro-router v1.0.2

Weekly downloads
42
License
-
Repository
-
Last release
1 year ago

micro-router

Route matcher for HTTP requests.

Install

npm i micro-router

Usage

Every route function is called with (request, response, params, queryParams).

  • request/response: values come from the http server.
  • params: Object. Keys are items in the path, like {id}.
  • queryParams: URLSearchParams object from the request URL

Node.JS example:

import router from 'micro-router'
import { createServer } from 'http';

const routes = {
  'GET /user/{id}': onUserGet,
  'DELETE /user/:id': onUserRemove,
  'POST /auth': onAuthenticate,
};

const fn = router(routes);

createServer(fn).listen(1234);
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.0

5 years ago

0.1.1

10 years ago

0.1.0

10 years ago