Skip to content

RESTful API for E-commerce operations with Jest,Supertest testcases

License

Notifications You must be signed in to change notification settings

ayushnanda21/eshop-2-API

Repository files navigation

eshop-API

RESTful API

Prerequisites

If you want to use a cloud based solution such as mLabs that is fine, you just need to replace the connection string with the one provided.

Installation

Clone the repo:

git clone https://github.com/ayushnanda21/eshop-2-API <YOUR_PROJECT_NAME> && cd <YOUR_PROJECT_NAME>

To start your own repository,

important: make sure you are in the cloned directory.

rm -rf .git
git init

This will remove the existing git history, and allow you to link it to a new repository.

.env

Lets create a .env file in the root of the project:

touch .env

Then put the following code in that .env except you should add your details.

MONGODB_URL=<your_mongodb_connection_string>
JWT_SECRET=<your_secret_key>

Scripts

"scripts": {
    "start": "nodemon app.js"
  },

Mongodb

  • Open the zip file mongodb came in, for mac users, go to the bin folder and double click mongod to start mongoDB. Windows users look for a similar file and run it.
  • Start the web page and server by typing npm run dev into terminal.
  • The site is now available at http://0.0.0.0:8080/

Running the tests

"scripts": {
    "test": "jest --forceExit --detectOpenHandles --maxWorkers=1",
    "test:watch": "jest --watch",
    "coverage": "jest --coverage"
  },

Deployment

Deployment information coming soon :)

Built With

  • node - As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications.
  • express - Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.
  • mongoDB - MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.
  • mongoose - Mongoose provides a straight-forward, schema-based solution to model your application data.
  • dotenv - Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env.
  • cryptojs- CryptoJS is a growing collection of standard and secure cryptographic algorithms implemented in JavaScript using best practices and patterns. They are fast, and they have a consistent and simple interface.
  • jsonwebtoken - JsonWebToken implementation for node.js.
  • cookie-parser - Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
  • bcrypt - bcrypt is a password hashing function.
  • passport - Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application.
  • multer - Multer is a node. js middleware for handling multipart/form-data , which is primarily used for uploading files. -jest- testing framework designed to ensure correctness of any JavaScript codebase. It allows you to write tests with an approachable, familiar and feature-rich API that gives you results quickly -supertest - Supertest module will make api request in jest tests, query our endpoints and return reponses to test conducted

Contributing

CONTRIBUTING.md

Author(s)

License

This project is licensed under the MIT License - see the LICENSE.md file for details