Simple MEAN tutorial – part 1 RESTful Day

Hi there,

This is a MEAN stack tutorial series and it is part 1. Basically this series will guide to create an application using MongoDB, ExpressJS, AngularJS and NodeJS and for quick front end design I use Bootstrap. For MEAN There are lot of tutorial out there on the web and just want to try out and with my understanding I want to share with the fellow developer.

I split up the tutorial into.

  1. About REST
  2. Creating a REST web service using NodeJS and ExpressJS.
  3. Connecting MongoDB to Node server via Mongoose.
  4. Creating AngularJS and Bootstrap front end.
  5. Making API calls from front end using AngularJS.

In part 1, I would like to start on What is REST Service

So, What is REST?

REST means “Representational State Transfer”  a software architectural style or pattern to create light weight, stateless web services. which use HTTP protocols to make web service calls.

The same logic of using HTML page request using URI via HTTP protocol is the key idea to make an web service calls in REST API instead of HTML page we go for Data call here. Data might be JSON or XML format or both, we can get response information in the HTTP header content-type like below to understand what sort of response it is.

For XML – text/xml and for JSON – application/json

The following methods used in REST API call to make CURD operation (Create, Update, Read and Delete)

  • GET – Making a web service call to read data from server.
  • POST – Making a web service call to create new data in server.
  • PUT – Making a web service call to update server data.
  • DELETE – Making a web service call to delete data in server.

Example API URL and what it does?


- consider this gives the product information where the product ID is 12345


- consider this will create an order for the customer  who is having ID 454545 with the POST requested product.


- consider this will update customer information who is having ID 454545 with the requested data.


- consider this will delete the order 67890 .

For further in detailed REST API explanation. Please refer to here.

Prerequisite for REST web service.

I hope you have installed Node and Mongo, if not visit to NodeJS and MongoDB you can find installation process.

As you may know NodeJS is JavaScript runtime environment for server-side and networking applications, it works in cross-platform and uses event-driven, non-blocking IO model.

ExpressJS is NodeJS application framework which has functional features to handle HTTP requests with their dependency modules it handles various HTTP methods

Morgan – log requests to the console.
Body Parser  – handles HTML POST and GET methods.
Method Override – handles DELETE and PUT  methods.


 And For MongoDB dependency we need Mongoose to connect and maintain the data model definition.

So the package.json looks like below.

 "name": "node-events",
 "version": "1.0.0",
 "description": "events app",
 "main": "server.js",
 "scripts": {
 "test": "echo \"Error: no test specified\" && exit 1"
 "keywords": [
 "author": "hashanddots",
 "license": "ISC",
 "dependencies": {
 "express": "~4.0.0",
 "morgan": "~1.0.0",
 "body-parser": "~1.5.0",
 "method-override": "~1.0.0",
 "mongoose": "^3.8.23"
 "devDependencies": {}

In Next part will get into basic project generation and setup using npm command and start up with building REST services using Node, Express and Mongo….. Part2

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>