What is Babel ?
$ 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
swagger-ui is a traditional npm module intended for use in single-page applications that are capable of resolving dependencies (via Webpack, Browserify, etc).
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.)
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.
2. Here, the logger function is not called because it placed after the api and there is no next exist in api.
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
$ 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…