Git Product home page Git Product logo

lotr-ofek-sdk's Introduction

LOTR API Server-Side SDK for Node.js

This SDK is designed for easy access into the https://the-one-api.dev/ APIs.

Supported Node versions

This version of the LaunchDarkly SDK is compatible with Node.js versions 12 and above.

Getting started

Start by running the following command:

npm install launchdarkly-node-server-sdk

Next, import the LOTR client in your application code:

const LOTRClient = require('lotr-ofek');

After you install and import the SDK, create a single, shared instance of LOTRClient. Specify your Bearer token here to authorize your application to connect to the API.

const client = new LOTRClient('YOUR_API_KEY');

If you don't have an API key yet, sign up here: https://the-one-api.dev/sign-up

All SDK methods are asynchronous and return a Promise, here is an example of how to use the SDK:

const response = await client.getBooks()

For more examples see the examples folder in this repository

For a full list of the SDK capabilities see LOTRClient in lotr-client

Pagination, Sorting, Filtering

The SDK supports pagination, sorting, filtering throughout the API using the params objct.

Pagination

Using limit, page and offset, you control the content you'll receive from the API.

Here is an example:

await client.getMovies({ params: { pagination: { limit: 20, page: 2}}})

Sorting

Results can be sorted according to any provided key that exists in the database.

The sort can be either ascending or descending and are accessed via LOTRClient#SortingOptions

await client.getChapters({ sorting: { key: 'chapterName', type: client.SortingOptions.DESC }, });

Filtering

You can filter out results according to the strategies in FilterOptions.

Here is an example of how to find all movies with budget of 200 million and above:

await client.getMovies({ filtering: [{ key: 'budgetInMillions', type: client.FilterOptions.GREATER_THAN, value: 200 }]});

Here is an example that showcases pagination, sorting and filtering altogether:

await client.getQuotes({ pagination: { limit: 20, page: 1}, sorting: { key: 'dialog', type: client.SortingOptions.DESC}, filtering: [{ key: 'dialog', type: client.FilterOptions.INCLUDE, value:['Aragorn','You lie.'] }], });

Learn more

Check out the complete API docs here: https://the-one-api.dev/documentation

Design

See DESIGN.md

Next steps

  • Add more unit tests, mainly around params-resolver
  • Add more corner cases checks in params-resolver

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.