🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

api-ninja

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-ninja

Handles the instantiation of multiple different APIs so they can be used across multiple Node modules.

0.0.4
latest
Source
npm
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

API-Ninja

Handles the instantiation of multiple different APIs so they can be used across multiple Node modules.

Basic Usage

For APIs that take parameters directly i.e. new MyAPI(param1, param2) you can use the following pattern. The first two parameters are required (key and module name), all subsequent parameters are passed through to the API's constructor.

const apis = require('api-ninja');

// Initialise and use the API immediately.
const tel  = apis.init('tel', require('twilio'), config.twilio.accountSID, config.twilio.authToken);

// Also use the API in another module.
const tel = apis.use('tel');

Advanced Usage

For APIs that require a more complicated setup you can pass in a function instead of a config object:

const apis = require('api-ninja');

// Initialise with function.
const myAPI  = apis.init('my-api', require('my-api-module'), (module) => {
  return new module.InitThis('abc', 123);
});

Keywords

api

FAQs

Package last updated on 15 Apr 2016

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