1.0.1 • Published 4 years ago

niffler-item-stock-reducer-subscriber v1.0.1

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

Niffler item stock reducer subscriber

Susbcriber that listen to the order created event in Niffler Nats Queue to get the shopping cart , and one by one reduce stock in our Stock Redis Database.

Installation

In order to get this project work, the first step is to get all configuration files needed for running (for example the .env file)... and for do that run the following command in the terminal to get via consul all the required files.

Notes: We encourage you to all the config files sensitive data keep in the config folder, because following this "practice" will keep just one folder to treath this kind of data , and will be easy to mantain.

# extract all the environment files needed to running the project 
# note: you need a valid consul token with access
gulp config #-t YOUR_CONSUL_TOKEN

Tip: All the configuration for treath the sensitive data keep in docker/config.hcl... so if you want to add more files or configurations, now you know what is the file that you need to edit ^^.

Docker

Simply and solid... just run the following command if you want to run inside a container docker.

Notes: To keep the same "drone pipeline", you need to create a .docker.env in the root directory with at least two required environment variables:

  • DOCKER_CONSUL_TOKEN: Consul Token with access to extract the configuration.
# docker build in interactive mode
docker build . && \
# docker run (if you want get inside the docker just append /bin/bash)
# the K8S_ENVIRONMENT is assigned in the k8s deployment via env args
docker run --env K8S_ENVIRONMENT=development --rm -it $(docker build -q .)

Gulp tasks

We use gulp as a task runner for a bunch of useful process, like for example:

  • "config": Download and extract all configuration files from consul inside the /config files, like .env files, certificates, secrets or all kind of sensitive data.
  • "validate": Some validation stuff like linting and things like that.
  • "docs": Build the Readme.md doc dynamically.
  • "build": Transpile the code from Typescript to Javascript.
  • "run": Run the code with nodemon to track the changes for ts files.
  • "publish": Publish the code (bump version and tagged), also build the Readme.md.

An example of running the validate task is easy as running the following command in your terminal:

# validate project
gulp validate

Subscriber manifiest

dockerversionlatest build
niffler-item-stock-reducer-subscriber1.0.02020-06-11T20:36:22.365Z