1.0.0 • Published 1 year ago

@briannpham/lotr-sdk v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Lord Of The Ring SDK

A JavaScript SDK for accessing Lord Of The Ring API

Getting Started

This SDK is developed for the below API. All routes requests will be prefixed with

https://the-one-api.dev/v2

Installing

Install this package into your project

npm install @briannpham/lotr-sdk

Import all necessary pre-defined SDK functions into your project. Refer to the documentation for all provided SDKs

const { getAllBooks, getAllChapters, lessThan } = require('@briannpham/lotr-sdk');

Example

All provides SDKs return a Promise. Promise chaining or async/await must be used to work with SDKs

const allLOTRBooks = async () => {
	const books = await getAllBooks();

	return books
};

or

getAllBooks()
	.then(books => console.log(books));

Testing

Refer to index.test.js for all SDK testing implementation

Example

it('Get all book chapters', async () => {
    const chapters = await getAllChapters();

    expect(chapters.length).toBeGreaterThan(0);
    expect(chapters[0]).toHaveProperty('chapterName');
})
it('Return a list of movies that have RottenTomato score less than 70', 
    async () => {
        const movies = await lessThan('movie', 'rottenTomatoesScore', 70);

        expect(movies.length).toBe(3);
        expect(movies[1].rottenTomatoesScore).toBe(64);
});