New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

impetuous

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impetuous

Incredibly Impetuous Node.js Router

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

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

Keywords

web

FAQs

Package last updated on 21 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts