# micro-router

> Route matcher for HTTP requests.

Latest version **1.0.2** (published 2024-05-09) · 0 weekly downloads

## Install

```sh
npm install micro-router
pnpm add micro-router
yarn add micro-router
bun add micro-router
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-05-09 |
| First published | 2015-08-31 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | darlanalves |

## Links

- npm: https://www.npmjs.com/package/micro-router
- npm.io page: https://npm.io/package/micro-router

## Recent versions

- 1.0.2 (latest) — 2024-05-09
- 1.0.1 — 2024-01-21
- 1.0.0 — 2024-01-21
- 0.2.0 — 2020-03-25
- 0.1.1 — 2015-08-31
- 0.1.0 — 2015-08-31

## README

# micro-router

Route matcher for HTTP requests.

## Install

```sh
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:

```ts
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);
```

---
_Source: https://npm.io/package/micro-router · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
