UNPKG

2.14 kBMarkdownView Raw
1# [@koa/router](https://github.com/koajs/router)
2
3> Router middleware for [Koa](https://github.com/koajs/koa). Maintained by [Forward Email][forward-email] and [Lad][].
4
5[![build status](https://github.com/koajs/router/actions/workflows/ci.yml/badge.svg)](https://github.com/koajs/router/actions/workflows/ci.yml)
6[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
7[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
8[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)
9[![license](https://img.shields.io/github/license/koajs/router.svg)](LICENSE)
10
11
12## Table of Contents
13
14* [Features](#features)
15* [Migrating to 7 / Koa 2](#migrating-to-7--koa-2)
16* [Install](#install)
17* [Typescript Support](#typescript-support)
18* [API Reference](#api-reference)
19* [Contributors](#contributors)
20* [License](#license)
21
22
23## Features
24
25* Express-style routing (`app.get`, `app.put`, `app.post`, etc.)
26* Named URL parameters
27* Named routes with URL generation
28* Match routes with specific host
29* Responds to `OPTIONS` requests with allowed methods
30* Support for `405 Method Not Allowed` and `501 Not Implemented`
31* Multiple route middleware
32* Multiple and nestable routers
33* `async/await` support
34
35
36## Migrating to 7 / Koa 2
37
38* The API has changed to match the new promise-based middleware
39 signature of koa 2. See the [koa 2.x readme](https://github.com/koajs/koa/tree/2.0.0-alpha.3) for more
40 information.
41* Middleware is now always run in the order declared by `.use()` (or `.get()`,
42 etc.), which matches Express 4 API.
43
44
45## Install
46
47[npm][]:
48
49```sh
50npm install @koa/router
51```
52
53
54## Typescript Support
55
56```sh
57npm install --save-dev @types/koa__router
58```
59
60
61## API Reference
62
63See [API Reference](./API.md) for more documentation.
64
65
66## Contributors
67
68| Name |
69| ---------------- |
70| **Alex Mingoia** |
71| **@koajs** |
72
73
74## License
75
76[MIT](LICENSE) © Alex Mingoia
77
78
79##
80
81[forward-email]: https://forwardemail.net
82
83[lad]: https://lad.js.org
84
85[npm]: https//www.npmjs.com