Skip to content

LukaszUrb/MovieApiSimple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Movie Api

REST Api created for fetching data from http://www.omdbapi.com/.

Technologies

  • Node.js + Express + TypeScript
  • MongoDB
  • Docker
  • PM2

Prerequisites

  • docker and docker-compose

Setup

  1. Download repository
  2. Provide .env file for api based on .env.api.example file
  3. Provide .env file for docker based on .env.docker.example file
  4. Run npm run up from main directory
  5. 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.

API

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

Postman

Using Postman for sending requests is highly recommended. You can find the postman config file in the postman directory.

CURL

Detailed request config when using curl:

HOME

curl localhost:3000/

CREATE MOVIE

curl -v -X POST localhost:3000/movies/add?title=...

Example:

curl -v -X POST localhost:3000/movies/add?title=Shrek

GET ALL MOVIES

curl localhost:3000/movies

GET MOVIE BY ID

curl localhost:3000/movies?id=...

Example:

curl localhost:3000/movies?id=6051e7e3f0eefe0010168941

ADD COMMENT

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"}'

GET ALL COMMENTS

curl localhost:3000/movies/comments

GET ALL COMMENTS FOR SPECIFIC MOVIE

curl localhost:3000/movies/.../comments/

Example:

curl localhost:3000/movies/6051e7e3f0eefe0010168941/comments/

INCOMING DATA FORMAT

MOVIE (MovieDocument)

_id: string;
title: string;
released: Date;
plot: string;
languages: LangDocument[];
director: PersonDocument[];
actors: PersonDocument[];

COMMENT (CommentDocument)

content: string;
creator: string;
movie: string;
createdAt: Date;
updatedAt: Date;

LANGUAGE (LangDocument)

name: string;

PERSON (PersonDocument)

name: string;

Notice that, data from general endpoints (/) always come as array but data from specific endpoints (?id) come as singular object.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published