Git Product home page Git Product logo

product-catalog's Introduction

Product Catalog

Build Status MIT Licence

The product is live at Heroku.

Contents

Getting Started

Start by cloning the repository using: git clone https://github.com/IamRaviTejaG/product-catalog.git followed by cd product-catalog.

Install all the dependencies (including the dev dependencies) using the npm install or npm i command. Once the dependencies are installed, use npm start to start the server.

Use an API testing tool like Postman or Insomnia to send/receive HTTP requests.

Dependencies & Packages

  • body-parser
  • dotenv
  • express
  • mongoose
  • morgan

Developer dependencies:

  • @babel/cli
  • @babel/core (Transpiling ES6 code for use with NodeJS)
  • @babel/present-env
  • @babel/register
  • chai (Assertion)
  • mocha (Testing)
  • nyc (Test coverage)
  • request
  • request-promise (For sending HTTP requests to the server while testing)
  • rimraf (The UNIX rm -rf command for Node)
  • standard (Linting)

Running locally

The .env file

The .env file holds the important variables for the whole application which include the database URL, database port, application port, etc.

NOTE: When running tests, make sure to point the MONGO_URL at the test database to avoid garbage collection in the main database.

npm scripts

The package.json file contains five scripts for running locally: linter, test, coverage, build & start.

  • "linter": "standard --fix"

Runs the StandardJS linter along with the --fix flag, which lints code to a great extent. The traceback (if one shows up) is the list of errors that need to be fixed manually.

  • "test": "mocha --require @babel/register --timeout 5000 --exit"

Runs only the tests.

  • "coverage": "nyc --reporter=text mocha --require @babel/register --timeout 5000 --exit"

Runs the test coverage & shows up detailed report.

  • "build": "rimraf dist/ && babel ./ --out-dir dist/ --copy-files"

Builds the project.

  • "start": "npm run build && node dist/index.js --no-deprecation"

First builds and then starts the server.

API endpoints

1. /insert

Request type: POST
Data parameters: name, category, brandName, images

2. /search

2.1. By name (/search/name/:searchQuery)
Request type: GET
Data parameters: name
2.2. By brandName (/search/brand/:searchQuery)
Request type: GET
Data parameters: brandname
2.3. By category (/search/category/:searchQuery)
Request type: GET
Data parameters: category

3. /update

3.1. By id (/update/byId/:id)
Request type: PUT
Data parameters: newName, newCategory, newBrandName, newImages
3.2. By name (/update/byName/:name)
Request type: PUT
Data parameters: newName, newCategory, newBrandName, newImages

4. /delete

4.1. By name (/delete/:name)
Request type: GET
Data parameters: name

© 2019 Ravi Teja Gannavarapu

product-catalog's People

Contributors

iamravitejag avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.