0.0.1 • Published 3 years ago

lotr-npm-sdk v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

LOTR npm SDK

A simple npm SDK for the Lord of The Rings API.

Install

npm install lotr-npm-sdk

Usage

import { LotrClient } from 'lotr-npm-sdk';

client = new LotrClient('my-api-key');

The client can be used as follows:

// Get all the books.
const books = client.books.getAll();

// Get one specific book.
const book = client.books.get("5cf58080b53e011a64671584");

// Can be filtered, sorted and matched dynamically.
const bigBudgetMovies = client.movies.movies.getAll({
    filtering: {
        range: { field: "budgetInMillions", greaterThan: 100 },
    },
});

The client wraps all endpoints of the lotr api:

const books = client.books.getAll();
const movies = client.movies.getAll();
const quotes = client.quotes.getAll();
const chapters = client.chapters.getAll();
const characters = client.characters.getAll();

Quotes and chapters can be obtained from a particular movie or book:

const chapters = client.books.getChapter("<book_id>")
const quotes = client.movies.getQuotes("<movie_id>")

The client supports pagination, filtering and sorting:

const options = { 
    filtering: { 
        field: "name", 
        includes: {
            values: [
                "The Return Of The King",
                "The Fellowship Of The Ring",
            ]
        }
    },
    pagination: {
        page: 1
    },
    sorting: {
        field: "name",
        asc: true 
    }
    
}

const movies = await client.movies.getAll(options);

If I had more time

  • Finish up tests for all services and options.
  • Validate the options input.
  • Better error messages.