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

welington-sdk

v1.0.1

Published

The Lord of the Rings SDK

Downloads

4

Readme

Table of Contents

Features

  • [x] Get all movies
  • [x] Get movie
  • [x] Get movie quote

Installing

Package manager

Using npm:

$ npm i welington-sdk

Using yarn:

$ yarn add welington-sdk

Using pnpm:

$ pnpm add welington-sdk

Once the package is installed, you can import the library using import or require approach:

import { getAllMovies, getMovie, getMovieQuote } from "welington-sdk";

If you use require for importing:

const { getAllMovies, getMovie, getMovieQuote } = require("welington-sdk");

Environment variables

An .env should be set in root with the following variables:

API_URL=https://the-one-api.dev/v2
API_KEY=your-api-key

API Key

To get an API key, you need to register at https://the-one-api.dev/sign-up. After that, you can get your API key.

Example

import { getAllMovie, getMovie, getMovieQuote } from "welington-sdk";

getAllMovie().then((movies) => {/* handle paginated result containing movies */})
getMovie('movie-id').then((movie) => {/* handle result containing the requested movie */})
getMovieQuote('movie-id').then((quotes) => {/* handle result containing movie quotes */})

Request and Response types

All requests and responses are typed. The following types are used:

Movie

Represents a Movie.

{
  "id": "movie-id",
  "name": "The Lord of the Rings Series",
  "runtimeInMinutes": 558,
  "budgetInMillions": 281,
  "boxOfficeRevenueInMillions": 2917,
  "academyAwardNominations": 30,
  "academyAwardWins": 17,
  "rottenTomatoesScore": 94
}

Quote

Represents a Quote.

{
  "id": "quote-id",
  "dialog": "Deagol",
  "movieId": "movie-id",
  "characterId": "character-id"
}

PageRequest

Useful for paginated requests. The page and pageSize properties are optional. If not provided, the default values are page = 1 and pageSize = 10.

{
  "page": 1,
  "pageSize": 10
}

PageResult

Response from paginated requests. All list requests will return a PageResult object containing the requested items.

{
  "items": [/*{...}, {...}*/],
  "total": 8,
  "page": 2,
  "pages": 5,
  "offset": 0
}

Testing

Unit tests

The unit tests execute core logic of the SDK, like the getAllMovies function. As its proposal, there is no communication with external dependencies, like the API.

To run the unit tests, execute the following command:

$ npm run test:unit

Integration tests

The integration tests verify if external dependencies are working as expected. To run it, configure an .env.test file with the following variables:

Note that the .env.test file should be created in the root folder and if possible with pre-prod environment values. Currently, the API does not have a pre-prod environment, so the .env.test file should be configured with the same values as the .env file. But be caution to execute these tests, because they will consume your API requests.

API_URL='https://the-one-api.dev/v2'
API_KEY='your-api-key'
$ npm run test:int