Skip to content
/ router Public

A router that works in Node.js, browser and Deno.

License

Notifications You must be signed in to change notification settings

egoist/router

Repository files navigation

@egoist/router

An Express-like router that works in Node.js, browser and Deno.

Install

For Node.js:

npm i @egoist/router
import { Router } from '@egoist/router'

For Deno:

import { Router } from 'https://unpkg.com/@egoist/router/mod.js'

Usage

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'

Supported route pattern

All patterns that Vue Router supports:

  • /user/:user: Parameter
  • /:orderId(\\d+): Custom regexp
  • /:chapters+: Repeatable params
  • Consult the Vue Router docs for more..

License

MIT © EGOIST

About

A router that works in Node.js, browser and Deno.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published