npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@emms21/lotr-sdk

v1.2.1

Published

This TypeScript SDK provides a streamlines option to interact with the /book endpoint in the Lord of the Rings API, enabling you to retrieve all books related to the Lord of the Rings series.

Downloads

8

Readme

TypeScript SDK for Lord of the Rings API /book endpoint

This TypeScript SDK provides a streamlines option to interact with the /book endpoint in the Lord of the Rings API, enabling you to retrieve all books related to the Lord of the Rings series.

Installation

To install this SDK follow this process: npm install lordoftheringsSDK

Getting Started

Once you have completed the install process, to get started and interact with the SDK follow this process

  1. Import the SDK function you need import { getBookData } from 'lordofringssdk';

  2. Use the imported function to retrieve all books in the Lord of the Rings series

Example Usage:

    const bookData = await getBookData();
    console.log('Book data:', bookData);

API Reference

getBookData()

This function retrieves all book data from the /book endpoint in the Lord of the Rings API. The function returns a promise that resolves to the book data as a JSON

Example Usage:

    import { getBookData } from 'my-book-sdk';
    const bookData = await getBookData();

Error Handling

Errors in the SDK are handled as followsL

  • If an ApiError is thrown, this means there was an issue with the API request. This will be shown through the status and error message.

  • If a generic error, that is not ApiError, is thrown, this means there was a non-API related issue, likely a network error. You can handle these errors separately.

Example Usage:

    try {
        const bookData = await getBookData();
    } catch (error) {
        if (error instanceof ApiError) {
            console.error('API Error:', error.message);
            console.error('API Status:', error.status);
        } else {
            console.error('Generic Error', (error as Error).message);
        }
    }

Testing

In order to run tests for the SDK, usin a testing framework like Jest. Refer to the book.test.ts file in the test directory for some example tests.

Configuration

The SDK is preconfigured with the API URL defined in the config.ts file. You can customize the API URL by modifying the apiUrl constant in the file mentioned.

Example Usage:

    // config.ts
    export const apiUrl = "http://127.0.0.1:8000;