Giter Site home page Giter Site logo

rubenfig / microservices-node-inventory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from launchany/microservices-node-inventory

0.0 0.0 0.0 7 KB

Microservices example that uses Node + Express with Docker support

License: MIT License

Dockerfile 3.04% JavaScript 96.96%

microservices-node-inventory's Introduction

This is a simple microservices example that uses Node.js + Express to provide a simple Product Quantities Service for tracking onhand inventories of products. Docker support is included for running locally or deploying to services such as Cloud66

Note: This isn't production-ready code. The service assumes no Mongo username/password, doesn't force SSL, or enforce security best practices. This is for demonstration and learning purposes only.

Running locally

Install the required dependencies:

npm install

Set an environment variable to point to the location of your MongoDB instance (e.g. 127.0.0.01 for localhost, or the specific IP/hostname if not localhost)

export MONGODB_ADDRESS=127.0.0.1

Run Express:

npm start

Running locally using Docker

Use docker-compose to build the service and mongodb containers (takes a few minutes the first time):

docker-compose build

Then start the the containers:

docker-compose up

Deploying to Cloud66

Cloud66 is a Manager Containers as a Service that supports deploying Docker containers onto one or more servers using a bring-your-own-cloud approach.

TODO

Interacting with the Products Service

Use Postman or cURL to directly interact with the API.

Create/update a product's onhand quantity, given the product identifier of 12345:

curl -X PUT http://127.0.0.1:8080/product_quantities/12345 -d "quantity_onhand=15"

{
  "product_id": "12345",
  "quantity_onhand": 15,
  "created_at": "2016-04-11T16:43:29.000Z",
  "_links": {
    "self": {
      "href": "/product_quantities/12345"
    }
  }
}

(make the same PUT call to update the onhand quantity at a later time)

Get the current onhand quantity for a product with the identifier 12345:

curl -X GET http://127.0.0.1:8080/product_quantities/12345

{
  "product_id": "12345",
  "quantity_onhand": 15,
  "created_at": "2016-04-11T16:43:29.000Z",
  "_links": {
    "self": {
      "href": "/product_quantities/12345"
    }
  }
}

microservices-node-inventory's People

Contributors

jhigginbotham 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.