eq-product-pricing
v0.0.0-development
Published
This is the service for Equinox Product Pricing
Downloads
3
Readme
EqProductPricing
Purpose
This project processes product pricing changes and sends them to Equinox.
Environment vars
This project uses the following environment variables:
| Name | Description | Required | Default Value | Accepted Values | | ----------------------- | ----------------------- | -------- | ------------- | --------------- | | NODE_ENV | Environment | Yes | DEV | DEV, TEST, PROD | | STORE_IDS | Equinox Store IDs | Yes | | | | BUSINESS_ID | Equinox Business ID | Yes | | | | OKTA_CLIENT_ID | Okta Client ID | Yes | | | | OKTA_CLIENT_SECRET | Okta Client Secret | Yes | | | | SOLACE_CONNECT_VPN_NAME | Solace Connect VPN Name | Yes | | | | SOLACE_CONNECT_USERNAME | Solace Connect Username | Yes | | | | SOLACE_CONNECT_PASSWORD | Solace Connect Password | Yes | | | | SOLACE_CONNECT_HOST | Solace Connect Host | Yes | | |
Pre-requisites
- Install Node.js version 14.0.0
- Access to the NextGen NPM Artifact Repository
Getting started
Initialize and start application
You will need to have CODEARTIFACT_AUTH_TOKEN set as an environment variable. To do this run:
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain nextgen --domain-owner 425432027451 --query authorizationToken --output text --profile nse-shd`
nse-shd
should be replace by whatever you name as your profile to gain access to the nse-shared-services
AWS environment. It is also helpful to add an alias to your .bash_profile if you use bash or .zshrc if you use zsh. That would look something like this:
alias set-codeartifact='export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain nextgen --domain-owner 425432027451 --query authorizationToken --output text --profile nse-shd`'
Install dependencies
yarn
Create .env file and add update variable values
NODE_ENV=dev
STORE_IDS='{"US":406, "CA":407}'
OKTA_CLIENT_ID='fakeId'
OKTA_CLIENT_SECRET='fakeSecret'
SOLACE_CONNECT_PASSWORD='fakePassword'
SOLACE_CONNECT_USERNAME=solace-cloud-client
SOLACE_CONNECT_HOST='wss://fakeHost:443'
SOLACE_CONNECT_VPN_NAME='fakeVpnName'
Build and run the project
yarn start
Project Structure
The folder structure of this app is explained below:
| Name | Description | | ----------------- | ---------------------------------------------------------------- | | __mocks__ | Contains jest mocks | | __tests__ | Contains jest tests | | config | Application configuration including environment-specific configs | | src | Contains source code | | publisher | Contains code to do a test publish | | src/index.js | Entry point to the application | | Dockerfile | File used by docker to containerize application | | .gitignore | List of files and directories for Git to ignore | | jest.config.js | Configuration options for Jest | | .eslintrc | Configuration options for ES Lint | | .prettierrc | Configuration options for prettier | | package.json | Contains npm dependencies as well as build scripts | | .prettierignore | List of files and directories for prettier to ignore | | cx.config | File needed for common pipeline to pass | | yarn.lock | Yarn state snapshot | | .gitlab-ci.yml | CI pipeline configuration | | node_modules | Contains package dependencies |
Project Scripts
All the different build steps are orchestrated via yarn scripts. yarn scripts basically allow us to call (and chain) terminal commands via npm.
| yarn Script | Description |
| ----------- | ---------------------------------------------------------------------------------------- |
| start
| Runs node on src/index.js. Can be invoked with yarn start
|
| pub
| Publishes test messages that you can use locally to test. Can be invoked with yarn pub
|
| test
| Runs tests with coverage using jest. Can be invoked with yarn test
|
| lint
| Runs ESLint on project files. Can be invoked with yarn lint
|
Testing
The tests and assertions use Jest.
Running tests using yarn Scripts
yarn test
ESLint
ESLint is a code linter that helps catch minor code quality and style issues.
ESLint rules
All rules are configured through .eslintrc
.
Running ESLint
To run ESLint you can call the ESLint task.
yarn lint // runs only ES lint
Logging
A dashboard has been added to Datadog for monitoring the application logs: Datadog Dashboard. This dashboard is a joint accumulation of logs for EqProductInventory, EqProductPricing, and EqProductData
Logging Metrics
To allow for better log visibility and acessibility, metric data is included in the application logs. Elements in the metric object can be used to fiter, sort and perform actions on application logs in Datadog.
An example you could enter something like this when filtering logs in the Search for
field in Datadog:
service:eq-product-data @metric.destination:"nuskin/product/pricing/created/v1/US/sap"
Here is a description for the elements in the Metric Object
| Name | Description | | ------------- | --------------------------------------------------------------- | | country | The country passed on the event | | destination | The solace topic were the message been processed came from | | correlationId | A unique id that ties all the logs in a transaction together | | eventType | Event type taken from destination in the metric | | skuId | The sku that the update has been sent for |
Sample metric data
{
"applicationMessageId": "ID:AMQP_NO_PREFIX:02020064-28b7-1eee-8b94-f2cdb6fae8de",
"country": "US",
"destination": "nuskin/product/pricing/created/v1/US/sap",
"correlationId": "02020064-28b7-1eee-8b94-f2cdb6fae8de",
"eventType": "created",
"senderTimestamp": 1690480880443,
"skuId": "01102945"
}