- Node.js v14 (this project use ESM feature and can not run without node
13
,14
or15
)- More details: https://nodejs.org/docs/latest-v14.x/api/esm.html
- Yarn (https://yarnpkg.com/lang/en/docs/cli/install/)
- Docker (optional but strongly recommended), install guide
- curl (optional but recommended since it's used in this doc to check routes), install guide
This project needs an API key of The Movie DB, it's configure as THEMOVIEDB_API_KEY
. So before anything, run:
$ export THEMOVIEDB_API_KEY=<my-api-key>
This command is the fastest way, it will run all the installation processes to you:
$ bash <(curl -s https://raw.githubusercontent.com/raphamorim/api-sample/main/install.sh)
Install dependencies:
$ yarn
Docker is optional but recommended, if you don't want to use docker, run the following commmand on project root and skip to Running section:
$ yarn start
Using docker, run the following commands to build and run the API:
$ make build && make run
Run docker ps
, to check the container running, it should return something like this:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e6b7a92af9d7 raphamorim/api-rest-sample "docker-entrypoint.sā¦" 9 seconds ago Up 8 seconds 0.0.0.0:8000->8080/tcp happy_buck
Check if the API is running:
$ curl localhost:8080/health
RUNNING
The API have 2 routes: /health
and /trailers
$ curl -X GET -H "Content-type: application/json" -H "Accept: application/json" -d '{"url":"https://content.viaplay.se/pc-se/film/bad-boys-for-life-2020"}' "http://localhost:8080/health"
RUNNING
$ curl -X GET -H "Content-type: application/json" -H "Accept: application/json" -d '{"url":"https://content.viaplay.se/pc-se/film/bad-boys-for-life-2020"}' "http://localhost:8080/trailers"
[
'https://www.youtube.com/watch?v=jKCj3XuPG8M',
'https://www.youtube.com/watch?v=-P-C6I-jZwQ'
]