Socket
Socket
Sign inDemoInstall

call

Package Overview
Dependencies
2
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    call

HTTP Router


Version published
Weekly downloads
52K
increased by23.56%
Maintainers
4
Install size
92.1 kB
Created
Weekly downloads
 

Readme

Source

call - Simple HTTP Router

Build Status

Lead Maintainer - Eran Hammer

Introduction

call is a simple node.js HTTP Router. It is used by popular hapi.js web framework. It implements predictable and easy to use routing. Even if it is designed to work with Hapi.js, you can still use it as an independent router in your app.

Example

const Call = require('call');

// Create new router
const router = new Call.Router();

// Add route
router.add({ method: 'get', path: '/' }, { label: 'root-path' });

// Add another route
router.add({ method: 'post', path: '/users' }, 'route specific data');

// Add another route with dynamic path
router.add({ method: 'put', path: '/users/{userId}' }, () => { /* ...handler... */ });

// Match route
router.route('post', '/users');
/* If matching route is found, it returns an object containing
    {
        params: {},                     // All dynamic path parameters as key/value
        paramsArray: [],                // All dynamic path parameter values in order
        route: 'route specific data';   // routeData
    }
*/


// Match route
router.route('put', '/users/1234');
/* returns
    {
        params: { userId: '1234' },
        paramsArray: [ '1234' ],
        route: [Function]
    }
*/

API

See the detailed API Reference.

Keywords

FAQs

Last updated on 03 Nov 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc