npm.io
2.4.0 • Published 2 years ago

@mutoe/koam-router

Licence
MIT
Version
2.4.0
Deps
0
Size
40 kB
Vulns
0
Weekly
0
Stars
3

Koam-router

Implement a simple Koa-like router to create a web application.

THIS FRAMEWORK HAVE NOT BEEN STRICTLY TESTED, PLEASE DO NOT USE IT IN PRODUCTION ! 许多功能未经严格测试,请勿用于生产目的!

Usage

import Koa from '@mutoe/koam-core'
import Router from '@mutoe/koam-router'

const app = new Koa()
const router = new Router()

app.use(router.routes())

Roadmap

  • new Route([options])
    • options.prefix
    • options.exclusive
    • options.host
  • router.<get|post|put|patch|delete|all>(path, ...middlewares)
    • Named routes
    • Match host
    • Multiple middlewares
  • Path matching (lightweight path-to-regexp)
    • named match
    • unnamed match
    • custom pattern match
    • modifiers
  • context.params
  • router.routes()
  • Nested routes
    • router.use([path], ...middlewares)
    • router.use([path], ...anotherRouter.routes())
  • router.prefix(path)
  • router.allowedMethods([options])
    • options.throw
    • options.notImplemented
    • options.methodNotAllowed
  • router.redirect(source, destination, [status])
  • router.route(name)
  • router.url(name, params, [options])
    • router.url(name, ...paramStrings, [options])
    • options.query
  • static method Router.url(path, params, [options])
    • Router.url(path, ...paramStrings, [options])
    • options.query
  • router.param(param, ...middlewares)

Keywords