• How to convert ES5 code to ES6 ?

What is Babel ?

Babel is a JavaScript compiler Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.

  1. install babel as devDependencies
  • First download babel-cli using below code to your project.
$ npm install -D babel-cli babel-preset-env babel --save

2. Then create .babelrc file using below code. This code will create one empty file in your computer.

$ touch .babelrc

3. Now in .babelrc file write below code.

4. Go to your package.json

swagger-ui is a traditional npm module intended for use in single-page applications that are capable of resolving dependencies (via Webpack, Browserify, etc).

Swagger UI example
  1. install regular node_modules that are express, body-parser.
npm i express body-parser

2. Here is the hello world simple code. As shown below.

3. Now, let’s start with swagger for that install swagger-jsdoc, swagger-ui-express.

npm i swagger-jsdoc swagger-ui-express

4. Now, for swagger-ui’s url write below code.

5. Now for GET api. (for easy code install Better Comments in vs code.)

1. GET

Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle. The next function is a function in the Express router which, when invoked, executes the middleware succeeding the current middleware.


  1. Here first called logger function because it called before the api.


2. Here, the logger function is not called because it placed after the api and there is no next exist in api.


jwt authentication
signup, login, logout APIs

JWT : JSON Web Token

JSON Web Token (JWT) is an open standard that defines a compact and self-contained way of securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed.

Authorization is the most common scenario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. …

Nodejs- multer for image upload to mongoose database

Multer is a node.js middle ware for handling multipart/form-data, which is primarily used for uploading files. It is written on top of busboy for maximum efficiency.


$ npm install --save multer

Let’s start

  1. Create new folder named node-multer
  2. run npm init -y
  3. install express, body-parser, multer, mongoose
$ npm i express body-parser multer mongoose

4. Create new file name app.js and Import all things

5. Create Schema and model

6. Now create api for example “Hello world”

7. Now, let’s add storage option, where image will save. In here, ‘./uploads/’ means…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store