Skip to main content

Node.js RESTful API Introduction

What is REST architecture?

REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods.
A REST Server simply provides access to resources and REST client accesses and modifies the resources using HTTP protocol. Here each resource is identified by URIs/ global IDs. REST uses various representation to represent a resource like text, JSON, XML but JSON is the most popular one.
HTTP methods
  • GET − This is used to provide a read only access to a resource.
  • PUT − This is used to create a new resource.
  • DELETE − This is used to remove a resource.
  • POST − This is used to update a existing resource or create a new resource.

RESTful Web Services

A web service is a collection of open protocols and standards used for exchanging data between applications or systems. Software applications written in various programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer. This interoperability is due to the use of open standards.
Web services based on REST Architecture are known as RESTful web services. These webservices uses HTTP methods to implement the concept of REST architecture. A RESTful web service usually defines a URI, Uniform Resource Identifier a service, which provides resource representation such as JSON and set of HTTP Methods.

Comments

Popular posts from this blog

Building a RESTful CRUD API with Node.js, Express, MongoDB

Used Libraries Express Validator Mongoose _____________Just 3 Steps________________ Step 1 Initialize the project npm init -y npm install --save-dev nodemon npm install express mongoose npm install validator Now go to the package.json and modifiy the scripts property like this. Then create folder call utils and create a file call db.js inside it. Here is my project structure. If  you haven't any idea to get MongoDB Connection String please refer first part from  here. Follow these set of code for RESTful API crud operations.    Step 2     db.js const mongoose = require('mongoose'); const validator = require('validator'); const url = 'MongoDB Connection String'; mongoose.connect(url,{useUnifiedTopology:true,useNewUrlParser:true}); const Schema = mongoose.Schema; const userSchema = new Schema({     name : {         type : String,         require : true,         trim : true     },     age : {         type

Routing and navigation in Angular

Angular provides a complete  routing  library with the possibility to  have  multiple  router  outlets, different path matching strategies, easy access to  route  parameters and  route  guards to protect components from unauthorized access. The  Angular router is  a core part of the  Angular  platform. It's very easy to implement routing and navigation. So now I'm going to implement simple application for routing. When we create project it also create  app-routing.module.ts file. Then I created 2 components call DepartmentList and EmployeeList. So now what I want is when I Press the the Employee list button I want to move Employee List form and when press the Department list button  want to  move Department List form. First step You must go to the  app-routing.module.ts  and you can see there is an array call routes. Then declare your components with name which you want appear on URL.   Don't remember import your component. And you must export your components.

An Introduction to Mongoose, Express for MongoDB With NodeJS

This is about how to connect with MongoDB from NodeJS. Used Libraries Express  Mongoose Steps... 1. npm init -y 2. npm install --save-dev nodemon              coppy this inside package.json                 "scripts":{                   "start": "node app",                  "dev": "nodemon app"           } 3. npm i express mongoose db.js (Inside the utils folder) const mongoose = require('mongoose'); const validator = require('validator'); const url = 'MongoDB Connection String'; mongoose.connect(url,{useUnifiedTopology:true,useNewUrlParser:true}) .then(res => console.log(res)) .catch(err => console.log(err)); app.js const express = require('express'); require('./utils/db'); const app = express(); app.listen(3000);  For execute npm run dev