Coder Social home page Coder Social logo

jijogeorge69 / node-movies-restful Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ivanmarban/node-movies-restful

0.0 1.0 0.0 24 KB

RESTful API using Node.js and MongoDB

License: GNU General Public License v2.0

JavaScript 95.28% Dockerfile 4.72%

node-movies-restful's Introduction

Simple RESTful API Using Node, Express 4 and MongoDB

A simple RESTful API server which supports basic CRUD operations.

Prerequisites

  • node.js
  • npm package manager
  • cURL
  • git
  • MongoDB
  • docker

Installation

Clone this repository and install node modules

$ git clone https://github.com/ivanmarban/node-movies-restful.git
$ cd node-movies-restful
$ npm install

Modify config/config.js for your environment and start server

$ node server.js

Docker

Run mongodb container

$ docker run -d -ti --name movies-database mvertes/alpine-mongo 

Run RESTful API container

$ docker run -d -ti -p 3000:3000 --name movies-back-end --link movies-database:db -e MONGODB_DB=movies -e MONGODB_HOST=db -e PORT=3000 ivanmarban/movies-back-end 

Testing the API using cURL

Get all movies:

$ curl -i -X GET http://localhost:3000/api/v1/movies 

Get movie with _id value of 5514677bda31962c1189aa23

$ curl -i -X GET http://localhost:3000/api/v1/movie/5514677bda31962c1189aa23

Delete movie with _id value of 5514677bda31962c1189aa23

$ curl -i -X DELETE http://localhost:3000/api/v1/movie/5514677bda31962c1189aa23

Add new movie

$ curl -i -X POST -H 'Content-Type: application/json' -d '{"title": "2001: A Space Odyssey","year": "1968","rated": "G","runtime": "160 min","genre": "Mystery, Sci-Fi","director": "Stanley Kubrick"}' http://localhost:3000/api/v1/movie

Modify movie with _id value of 5514677bda31962c1189aa23

$ curl -i -X PUT -H 'Content-Type: application/json' -d '{"title": "2001: A Space Odyssey","year": "1968","rated": "G","runtime": "160 min","genre": "Sci-Fi","director": "Stanley Kubrick"}' http://localhost:3000/api/v1/movie

REST API

URL HTTP Verb POST Body Result
/api/v1/movies GET empty Return all movies
/api/v1/movie POST JSON string New movie created
/api/v1/movie/:id GET empty Return single movie
/api/v1/movie/:id PUT JSON string Updates an existing movie
/api/v1/movie/:id DELETE empty Deletes existing keyword

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.