0.0.32 • Published 3 years ago

@typoerr/router v0.0.32

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@typoerr/router

npm npm bundle size

Router for Node.js and Browser.

Install

npm i @typoerr/router

https://www.npmjs.com/package/@typoerr/router

Path expression

See lukeed/regexparam.

Example

import { route, compose, ResolveHint } from '@typoerr/router'

const router = compose([
  route('GET', '/', (ctx) => ctx.pathname),
  route('GET', '/err', (ctx) => Promise.reject(ctx.pathname)),
])

async function main(context: ResolveHint) {
  const notfound = () => Promise.reject(new Error('404 NotFound'))
  try {
    const reulst = await router(context, notfound)
    console.assert(result === context.pathname)
  } catch(err) {
    console.error(err)
  }
}

And See test/example/*.test.ts.

API

See src/route.ts and test/route.test.ts.

Inspired

0.0.32

3 years ago

0.0.31

3 years ago

0.0.30

3 years ago

0.0.29

3 years ago

0.0.28

3 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago