1.2.4 • Published 11 months ago

@ply-ct/ply-movies v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

ply-movies

A simple, self-contained movies API for REST service testing.
The included data contains horror movies from the 1930s.

The ply-movies API is used by Ply in its automated tests and tutorials.

Install:
npm install -g @ply-ct/ply-movies

Start:
ply-movies start

Stop:
ply-movies stop

Configuration

CLI OptionEnvironment VariableDefaultUsage
--portSERVER_PORT3000API server should listen on this port
--indentRESPONSE_INDENT0Format JSON response with this number of spaces
--fileMOVIES_FILEmovies.jsonLocation of writeable movies JSON file (created on first update)
--readonlyREADONLY_APIfalseDisallow POST, PUT, PATCH and DELETE requests
--delay0Impose a delay in milliseconds on response

For example: ply-movies start -p 3001

Sample queries

These URLs point against ply-ct.org. However, the main point of ply-movies is to be hosted locally so that during development you can exercise all API methods, including POST, PUT, PATCH and DELETE.

All movies:

Movies made in 1931:

Movies made after 1935:

Movies sorted by rating in descending order:

Movies with a rating of 3.5 or above, sorted by year:

Find all movies with Bela Lugosi:

Retrieve the first page of movies, with page size = 25

Retrieve the second page of movies, with page size = 25

Retrieve the first page of movies from a list sorted by year

Retrieve the first page of movies featuring Boris Karloff, sorted by year

Sample POST

Create a movie by posting to /movies:

{
  "title": "The Case of the Howling Dog",
  "year": 1934,
  "credits": [
    {
      "name": "Alan Crosland",
      "role": "director"
    },
    {
      "name": "Warren William",
      "role": "actor"
    },
    {
      "name": "Mary Astor",
      "role": "actor"
    },
    {
      "name": "Allen Jenkins",
      "role": "actor"
    },
    {
      "name": "Grant Mitchell",
      "role": "actor"
    },
    {
      "name": "Helen Trenholme",
      "role": "actor"
    }
  ],
  "webRef": {
    "ref": "tt0024958",
    "site": "imdb.com"
  }
}

More examples

See Ply tests in the ply-demo repository.