0.3.1 • Published 4 years ago

impetuous v0.3.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Build Status GitHub license

Impetuous

Impetuous is simple and fast Node.js Router for building web applications.

Impetuous uses Map and the freestyle implementation of Radix Tree for different types of routes. Due to this you achieve very high speed in all cases.

Installation

$ npm install impetuous

How to Use?

const http = require('http')
const Impetuous = require('impetuous')

const router = new Impetuous()

// Third handler argument can be, what you want
router.add('GET', '/path', () => {
  // Handle something
})

router.add('POST', '/path', () => {
  // Handle something
})

// Third handler argument can be, what you want
router.add('DELETE', '/path/:param', [
  () => {
    // Handle something
  },
  () => {
    // Handle something
  }
])

router.find('GET', '/path')
// -> { handler: [Function] }

router.find('GET', '/path/') // <- '/' at the end works
// -> { handler: [Function] }

router.find('POST', '/path')
// -> { handler: [Function] }

router.find('DELETE', '/path/123')
// -> { handler: [[Function, Function]], params: { param: 123 } }

API

add(method: String, path: String, handler: Any)

Adds a new handler for the method and path.

find(method: String, path: String)

Finds the handler for the method and path.

Returns Object with the following fields:

handler: Any what you added

params: Object contains params from path /path/:param <- like this

Usage Example

Library/Framework Dragonrend uses Impetuous as Router. Extension example: class Router

Author

Egor Repnikov - GitHub

License

This project is licensed under the MIT License - see the LICENSE file for details

0.3.1

4 years ago

0.3.0

4 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

2.0.0

10 years ago