List of technologies to create the movie api
Server: Node, Express, Mongoose
Database: MongoDB
GET /movies
curl --location --request GET 'http://localhost:8000/movies' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>'
{
"status": true,
"message": "Successfully fetched user movies",
"data": [
{
"_id": "6248cd97c025561ae49373d6",
"Title": "The Flash",
"Released": "2014-10-06T23:00:00.000Z",
"Genre": "Action, Adventure, Drama",
"Director": "N/A",
"user": 123,
"createdAt": "2022-04-02T22:26:31.582Z"
},
{
"_id": "6248ce65b973a06b374718ae",
"Title": "Super Girl",
"Released": "2011-11-18T23:00:00.000Z",
"Genre": "Action, Comedy, Fantasy",
"Director": "N/A",
"user": 123,
"createdAt": "2022-04-02T22:29:57.068Z"
},
],
"error": null
}
POST /movies
curl --location --request POST 'http://localhost:8000/movies' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"title": "Amazing spider man"
}'
"status": true,
"message": "Successfully saved movie",
"data": {
"Title": "The Amazing Spider-Man",
"Released": "2012-07-02T23:00:00.000Z",
"Genre": "Action, Adventure, Sci-Fi",
"Director": "Marc Webb",
"user": 123,
"_id": "624a4205094a659a4aeaf9f3",
"createdAt": "2022-04-04T00:55:33.176Z",
"__v": 0
},
"error": null
Basic
users are restricted to create only 5 movies per month (calendar month).Premium
users have no limits in creating movies.
Clone the project
$ git clone <repository link>
Go to the movie directory
$ cd <project directory>/movie
Install dependencies
$ npm install
Start the server
$ npm run start
Dockerize the services and run it in the background
$ docker compose -f docker-compose.yml up -d
Stop the services
$ docker-compose down
To run this project, you will need to add the following environment variables to your .env file.
JWT_SECRET
, PORT
, MONGO_URI
, API_KEY
To generate tokens in auth service you need to provide env variable
JWT_SECRET
. It should be a string value. You should use the same secret in
the API you're building to verify the JWT tokens.
Default PORT
for Movie Service is 4000.
The URI that lets you connect to a MongoDB service either in your local machine.
OMDb API The Open Movie Database
is a free API service where you can search for
movie information. To be able to pull data from their database, you need an
API Key that authorized you to get a movie data in their platform.
You can create your own API Key here.
To run tests, run the following command
npm run test
https://documenter.getpostman.com/view/7357882/UVysxbdB
- Put the env in secret rather then exposing them in the main.yml file
- covered more test
- uses a dynamic token in the test