https://github.com/cheft/minrouter
a micro middleware router for isomorphic javaScript web apps
https://github.com/cheft/minrouter
isomorphic router universal
Last synced: about 1 year ago
JSON representation
a micro middleware router for isomorphic javaScript web apps
- Host: GitHub
- URL: https://github.com/cheft/minrouter
- Owner: cheft
- Created: 2015-07-06T09:24:15.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-07-21T03:26:45.000Z (almost 9 years ago)
- Last Synced: 2025-05-11T07:15:11.812Z (about 1 year ago)
- Topics: isomorphic, router, universal
- Language: JavaScript
- Homepage: http://sandbox.runjs.cn/show/dxi5lgcx
- Size: 1.21 MB
- Stars: 159
- Watchers: 5
- Forks: 29
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# minrouter
a micro middleware router that can be used in both client-side (e.g. dot.js, vue, react, preact) and server-side applications (e.g. Node.js/Express, Koa)
## features
* support koa
* support express
* support browser pushState & replaceState
* middleware router, API like express
## preview

## install
npm install minrouter
## build
npm run build
## run demo
```shell
# build the web code
npm run demo
# http://localhost:3000
npm run express
or
# http://localhost:4000
npm run koa
or
# http://localhost:4000
npm run preact
```
## usage
> see demo directory code
## api
* Router.get(path, fn)
* Router.addResMethod(name, fn)
* Router.go(path, isReplace) __only browser__
* Router.back() __only browser__
* Router.proxyLinks(nodes) __only browser__
* req.query & req.params, this.ctx, this.ctx.res
> see src/minrouter.js