Giter Site home page Giter Site logo

inventorysystem's Introduction

Inventory System

An inventory system which could be used by any retailer/hospitality business. Helps to perform actions such as updating stock levels and adding or removing new products etc.

Technical Information

Routes

  • /healthcheck : Shows the app is up with a basic JSON respose including current date and time.
  • /item : Accepts a POST request with a JSON body allowing you to create an item through the API and store it in the database.
  • /item/:itemId : Allows you to retrieve an item from the database with a GET request and an itemId appended to the URL.

Prequesites

Node.js, npm, MongoDB, TypeScript, Docker

Development Environment (Docker)

You will need docker setup on your environment to be able to run this through Docker. I suggest coming here and installing the community edition. Then you can simply do:

  • Run docker build -t inventory-system .
    • NOTE: The first build will take the longest due to packages being pulled in etc. Subsequent builds should be a lot faster.
  • Run docker-compose up or docker-compose up -d to run the logging in detached mode.
  • Visit http://localhost:3001/healthcheck to ensure that the app spun up correctly.

Development Environment (Locally)

You will need Node.js, npm and MongoDB all up and running on your local environment. In terms of the MongoDB config in the config/default.json, feel free to modify the connection string to what you have setup with your version of MongoDB. Then you can simply do the following:

  • Run npm install
  • Run npm start
  • Visit http://localhost:3001/healthcheck or - depending on your /etc/hosts file - http://127.0.0.1:3001/healthcheck, to ensure that the app spun up correctly.

Running Tests

Run the tests to make sure everything is okay. To do this simply run: npm test.

To test the API once it is spun up, you can use the following curl command to create an item in the database:

curl -H "Content-Type: application/json" -X POST http://localhost:3001/item -d '{ "itemName": "Milk", "description": "This is a carton of Milk.", "price": "0.99" }'

You can then use the _id value from the response of that request to perform a fetch of the same item. You can simply go to your browser and visit http://localhost:3001/item/:itemId or you can use this curl request:

curl http://localhost:3001/item/3x4mp13-1t3m-1D - replcacing "3x4mp13-1t3m-1D" with your previous requests ID.

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.