https://github.com/magicdawn/impress-router-table
Sails.js like routing for koa.js
https://github.com/magicdawn/impress-router-table
express-router koa koa-middleware koa-router sails
Last synced: 6 months ago
JSON representation
Sails.js like routing for koa.js
- Host: GitHub
- URL: https://github.com/magicdawn/impress-router-table
- Owner: magicdawn
- License: mit
- Created: 2016-12-02T15:35:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-12T05:04:03.000Z (about 9 years ago)
- Last Synced: 2025-03-11T02:01:31.669Z (over 1 year ago)
- Topics: express-router, koa, koa-middleware, koa-router, sails
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# impress-router-table
> Sails.js like routing for koa.js
[](https://travis-ci.org/magicdawn/impress-router-table)
[](https://codecov.io/gh/magicdawn/impress-router-table)
[](https://www.npmjs.com/package/impress-router-table)
[](https://www.npmjs.com/package/impress-router-table)
[](http://magicdawn.mit-license.org)
## Install
```sh
$ npm i impress-router-table --save
```
## API
```js
const routing = require('impress-router-table');
```
### `routing(rootdir, router)`
returns a koa middleware
```js
const app = new (require('koa'))
app.use(routing(__dirname + '/api'))
app.listen(9000)
```
#### `router`
router must support `get` / `post` / etc HTTP methods
defaults to an new impress-router instance
#### Folder structure in `rootdir`
for example in previous example, `__dirname + '/api'`,
take a look at [test/demo/api/](test/demo/api/)
```
test/demo/api
├── controllers
│ ├── PolicyTestController.js
│ └── RouteTestController.js
├── policies
│ ├── auth.js
│ └── bar.js
├── policy.js # policy config
└── routes.js # routes config
2 directories, 6 files
```
## Changelog
[CHANGELOG.md](CHANGELOG.md)
## License
the MIT License http://magicdawn.mit-license.org