1.0.1 • Published 3 years ago

rest_api-basicone-api v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Simple API In NodeeJs

In this example application, we use Swagger JSDoc and Swagger UI Express to automatically generate OpenAPI documentation. We create a simple NodeJS API server to demonstrate the power of autogenerated documentation.

Required Dependancy

S.NoList of CommandsDescription
1npm initThis command initializes a package.json file with all the settings that the creator wishes to include.
2package.jsonThe user will be prompted to enter configuration details one after the other. Apart from the normal settings, user can also open the package.json file and add/delete configuration settings such as additional scripts or dependencies etc...-
3npm installOnce the package.json file is configured, user can simply run this command to install all the dependencies, devDependencies and everything mentioned in the package.json file in one go.
4npm i -g jestThis command enables the user to install jest framework globally for unit testing 7 code coverage.
5npm i -g jsdocThis command enables the user to install jsdoc tool globally for documentating his/her code.
6npm i -g eslintThis command enables the user to install the eslint tool globally for linting purposes. *Refer to NOTE.
7npm eslint --initThis command enables the user to setup the eslint according to the developer styles and rules
8npm i -g axiosApart from jest, we've added the support of axios for testing our api. This command enables us to install axios globally.
9npm eslint file.jsAccording to package.json configuration, this command will fix all fixable possible errors in all .js files in the src & tests directory.
10npm run docAccording to package.json configuration, this command will produce the documentation reports for all .js files.
11npm testThis command will run the tests for desired project along with code coverage.
12npm publishThis command will simply publish the package file to the npm global package registry. If already present, it will follow semantic versioning.

Running the Server

With NodeJS installed, you can started the server by running,

node src/app.js

OR

npm run start

Accessing the Docs

With your local server running, the generated docs are available here: http://localhost:3000/api-docs

Development

This simple server can be easily extended. After cloning this repository you can start developing locally.

Locally (without Docker)

  1. Install Nodemon, Nodemon will watch for file changes and restart the NodeJS process. This allows for faster development and testing.
npm install -g nodemon
  1. With Nodemon installed, start the server using Nodemon
nodemon src/app.js

OR

npm run start

Author  : Yograj thakur Date      : 09/11/2020