nikhil-joshi-lotr-sdk-2

1.0.1 • Public • Published

Lord of the Rings SDK

Installation:

Using npm:

    npm i nikhil-joshi-lotr-sdk-2

Usage:

In Node.js:

    // 'require' Syntax
    // Get the default api function export to initialize the lib
    const api = require('nikhil-joshi-lotr-sdk-2')
    // Initialize the lib with the auth token
    api('authorization-token')
    
    const {movies, quotes} = require('nikhil-joshi-lotr-sdk-2')
    // Example api call
    movies.getAll().then(res => {
        console.log(res.data)
    })
    
    quotes.getAll().then(res => {
        console.log(res.data)
    })
    // 'import' syntax
    import api, {movies, quotes} from 'nikhil-joshi-lotr-sdk-2'
    
    // Initialize the lib with the auth token
    api('authorization-token')
    
    movies.getAll().then(res => {
        console.log(res.data)
    })

    quotes.getAll().then(res => {
        console.log(res.data)
    })

Optional Params:

- Some of the methods take an optional params object argument. The details of the supported keys are as follows:

  • limit - Total items to return. Defaults to 10
  • page - The page number of the dataset
  • offset - The data offset
  • sortKey - The field in the data set to sort on.
  • sortDirection- asc or desc. Defaults to asc
  • match: Object with options to match or unmatch on a specific key
    • key - The field in the dataset
    • value - The value to match
    • negate - If true, returns all not matching values
  • include
    • key - The field in the dataset
    • value - The values to include (comma-separated)
  • exclude
    • key - The field in the dataset
    • value - The values to exclude (comma-separated)
  • existsKey- The field name in the data set. If specified, only the items that contains the specified key will be returned.
  • doesnotExistKey- The field name in the data set. If specified, only the items that does not contain the specified key will be returned.
  • regex
    • key - The field in the dataset
    • value - The regex for the field
    • negate - If true, returns all not matching the regex
  • compare
    • key - The field in the dataset for comparison
    • value - The value for the comparison
    • operator - The comparison operator. See all possible values below.
      • gt - corresponds to '>',
      • lt - corresponds to '<',
      • eq - corresponds to '=',
      • geq - corresponds to '>=',
      • leq - corresponds to '<=',

Tests:

Running the unit tests:

    npm run test

Readme

Keywords

none

Package Sidebar

Install

npm i nikhil-joshi-lotr-sdk-2

Weekly Downloads

4

Version

1.0.1

License

ISC

Unpacked Size

12.5 kB

Total Files

14

Last publish

Collaborators

  • nikhilnvj