An Express-like router that works in Node.js, browser and Deno.
For Node.js:
npm i @egoist/router
import { Router } from '@egoist/router'
For Deno:
import { Router } from 'https://unpkg.com/@egoist/router/mod.js'
const router = new Router()
router.get('/user/:user', (params) => {
console.log(params.user)
})
router.get('/', () => {
// do something
})
const matches = router.find('GET', '/user/egoist')
for (const m of matches) {
m.handler(m.params)
}
// prints: 'egoist'
All patterns that Vue Router supports:
/user/:user
: Parameter/:orderId(\\d+)
: Custom regexp/:chapters+
: Repeatable params- Consult the Vue Router docs for more..
MIT © EGOIST