npm's personal messenger
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    router-corepublic

    node-router-core

    Simple URL/path-based router for node.js

    Install

    npm install router-core
    

    Examples

    Define your router:

    var router = new Router
     
    router.add('/foo', value) // literal path
    router.add('/bar/:param', value) // path with parameter

    Get a route

    var route = router.route(path)
    route.value // original value passed into add method
    route.params // object with parameter matches
    route.nextRoute // recursive callback to get the next route if this one isn't good enough

    Internal API

    More advanced use-cases require accessing the route list. This can be done by accessing the router.routes array in the following format:

    router.routes.forEach(function(route) {
        route.path // original path from add method
        route.value // original value from add method
        route.test(path) // function that returns a parameters object if the path matches, or false
    })

    License

    zlib license LICENSE.

    Keywords

    none

    install

    npm i router-core

    Downloadsweekly downloads

    2

    version

    0.1.0

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar