# @mutoe/koam-router

> A lightweight router for Koam.

Latest version **2.4.0** (published 2024-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mutoe/koam-router
pnpm add @mutoe/koam-router
yarn add @mutoe/koam-router
bun add @mutoe/koam-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 | 2.4.0 |
| Published | 2024-07-25 |
| First published | 2023-05-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 40.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | mutoe |
| Maintainers | mutoe |
| Keywords | koa, koam, http-server, router |

## Links

- npm: https://www.npmjs.com/package/@mutoe/koam-router
- Repository: https://github.com/mutoe/koam
- Homepage: https://github.com/mutoe/koam/tree/main/packages/koam-router
- Issues: https://github.com/mutoe/koam/issues
- npm.io page: https://npm.io/package/@mutoe/koam-router

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 2.4.0 (latest) — 2024-07-25
- 2.3.1 — 2024-07-19
- 2.2.0 — 2024-01-15
- 2.1.0 — 2023-08-08
- 2.0.2 — 2023-07-25
- 2.0.1 — 2023-06-09
- 2.0.0 — 2023-06-09
- 2.0.0-alpha.0 — 2023-06-09
- 1.1.1 — 2023-06-08
- 1.1.0 — 2023-06-08
- 1.0.1 — 2023-06-01
- 1.0.0 — 2023-06-01
- 0.3.2 — 2023-05-17
- 0.3.1 — 2023-05-16
- 0.3.0 — 2023-05-16
- … 6 more at https://npm.io/package/@mutoe/koam-router/versions

## README

# Koam-router

Implement a simple Koa-like router to create a web application.

THIS FRAMEWORK HAVE NOT BEEN STRICTLY TESTED, PLEASE DO NOT USE IT IN PRODUCTION !
许多功能未经严格测试，请勿用于生产目的！

## Usage

```ts
import Koa from '@mutoe/koam-core'
import Router from '@mutoe/koam-router'

const app = new Koa()
const router = new Router()

app.use(router.routes())
```

## Roadmap

- [x] `new Route([options])`
  - [x] `options.prefix`
  - [ ] `options.exclusive`
  - [ ] `options.host`
- [x] `router.<get|post|put|patch|delete|all>(path, ...middlewares)`
  - [x] Named routes
  - [ ] Match host
  - [x] Multiple middlewares
- Path matching (lightweight `path-to-regexp`)
  - [x] named match
  - [x] unnamed match
  - [x] custom pattern match
  - [x] modifiers
- [x] `context.params`
- [x] `router.routes()`
- Nested routes
  - [x] `router.use([path], ...middlewares)`
  - [x] `router.use([path], ...anotherRouter.routes())`
- [x] `router.prefix(path)`
- [x] `router.allowedMethods([options])`
  - [ ] `options.throw`
  - [ ] `options.notImplemented`
  - [ ] `options.methodNotAllowed`
- [x] `router.redirect(source, destination, [status])`
- [x] `router.route(name)`
- [x] `router.url(name, params, [options])`
  - [x] `router.url(name, ...paramStrings, [options])`
  - [x] `options.query`
- [x] static method `Router.url(path, params, [options])`
  - [x] `Router.url(path, ...paramStrings, [options])`
  - [x] `options.query`
- [x] `router.param(param, ...middlewares)`

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