Skip to content

Latest commit

 

History

History
116 lines (96 loc) · 3.65 KB

README.md

File metadata and controls

116 lines (96 loc) · 3.65 KB

routify

Nice little Trie-based HTTP router



Built with ❤︎ by tiaanduplessis and contributors

Table of Contents

Table of Contents
  • About
  • Install
  • Usage
  • Contribute
  • License
  • About

    Built on top of routington. If your looking for something fast, try find-my-way instead.

    Install

    $ npm install @tiaanduplessis/routify
    # OR
    $ yarn add @tiaanduplessis/routify

    Usage

    const routify = require('@tiaanduplessis/routify')
    const http = require('http')
    
    const app = routify()
    
    app.use(({ req }, next) => {
      console.log(`Request to ${req.url}`)
      next()
    })
    
    app.route({
      url: '/',
      method: 'GET',
      handler: (ctx, next) => {
        ctx.res.end('Hai')
      }
    })
    
    app.route({
      url: '/foo',
      method: 'GET',
      handler: (ctx, next) => {
        ctx.res.end('foo!')
      }
    })
    
    http.createServer(app.lookUp).listen(8888)

    Contributing

    Contributions are welcome!

    1. Fork it.
    2. Create your feature branch: git checkout -b my-new-feature
    3. Commit your changes: git commit -am 'Add some feature'
    4. Push to the branch: git push origin my-new-feature
    5. Submit a pull request :D

    Or open up a issue.

    License

    Licensed under the MIT License.