@ply-ct/ply-movies
v1.3.1
Published
Simple, self-contained movies API for REST testing
Downloads
21
Readme
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 Option | Environment Variable | Default | Usage | | ---------- | -------------------- | ------- | ------| | --port | SERVER_PORT | 3000 | API server should listen on this port | | --indent | RESPONSE_INDENT | 0 | Format JSON response with this number of spaces | | --file | MOVIES_FILE | movies.json | Location of writeable movies JSON file (created on first update) | | --readonly | READONLY_API | false | Disallow POST, PUT, PATCH and DELETE requests | | --delay | | 0 | Impose a delay in milliseconds on response | | --quiet | | false | Quiet server startup | --websockets | | false | Allow websocket subscribers
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?year=>1935 (note: > is part of query value)
Movies sorted by rating in descending order:
Movies with a rating of 3.5 or above, sorted by year:
- /movies?rating=>=3.5&sort=year (note: >= is prepended to query value)
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"
}
}
WebSocket updates
Subscribe to movie updates on a WebSocket:
/updates
More examples
See Ply tests in the ply-demo repository.