REST Api created for fetching data from http://www.omdbapi.com/
.
- Node.js + Express + TypeScript
- MongoDB
- Docker
- PM2
docker
anddocker-compose
- Download repository
- Provide
.env
file forapi
based on.env.api.example
file - Provide
.env
file fordocker
based on.env.docker.example
file - Run
npm run up
from main directory - To stop app run
npm run down
from main directory
For simplifying the application running process, .env.api.example
and .env.docker.example
contains a valid configuration, so you can simply rename these files to .env
and everything will work.
Method | URI | Middleware | Description |
---|---|---|---|
GET | / | - | home |
POST | /movies/add?title={title} | - | add movie |
GET | /movies | - | fetch all movies |
GET | /movies?id={id} | - | fetch the movie |
POST | /movies/{id}/comments/add | - | add comment to the movie |
GET | /movies/{id}/comments/ | - | get all comments for the movie |
GET | /movies/comments | - | get all comments |
Using Postman
for sending requests is highly recommended. You can find the postman config file in the postman
directory.
Detailed request config when using curl:
curl localhost:3000/
curl -v -X POST localhost:3000/movies/add?title=...
Example:
curl -v -X POST localhost:3000/movies/add?title=Shrek
curl localhost:3000/movies
curl localhost:3000/movies?id=...
Example:
curl localhost:3000/movies?id=6051e7e3f0eefe0010168941
curl -v -X POST localhost:3000/movies/.../comments/add -H 'Content-Type: application/json' -d '{"creator":"...", "content":"..."}'
Example:
curl -v -X POST localhost:3000/movies/6051e7e3f0eefe0010168941/comments/add -H 'Content-Type: application/json' -d '{"creator":"Yoda", "content":"May the power be with you"}'
curl localhost:3000/movies/comments
curl localhost:3000/movies/.../comments/
Example:
curl localhost:3000/movies/6051e7e3f0eefe0010168941/comments/
_id: string;
title: string;
released: Date;
plot: string;
languages: LangDocument[];
director: PersonDocument[];
actors: PersonDocument[];
content: string;
creator: string;
movie: string;
createdAt: Date;
updatedAt: Date;
name: string;
name: string;
Notice that, data from general endpoints (/
) always come as array but data from specific endpoints (?id
) come as singular object.