The ZaneRay Express BigCommerce Middleware package contains components for working with the BigCommerce API in a Node environment. There are three main component areas.
- BigCommerce Storefront Configuration
- BigCommerce Middleware API Routing
- BigCommerce API Services
You can run a stock instance of the Express BigCommerce Middleware package by creating a project with a package.json like the following
{
"name": "express-bigcommerce-middleware-example",
"version": "0.0.1",
"description": "Example for running the stock ZaneRay BigCommerce Middleware express instance",
"author": "The ZaneRay Group",
"scripts": {
"start": "node node_modules/@zaneray/express-bigcommerce-middleware/lib/index.js",
"build": "echo nothing to see here, move along..."
},
"dependencies": {
"@zaneray/express-bigcommerce-middleware": "4.2.0"
}
}
CORS_WHITELIST=<comma delimited list of allows origins, e.g. http://www.mysite.com,https://www.mysite.com>
PORT=<port that the instance should listen on, 3000 is the default>
CUSTOMER_TOKEN_APP_CLIENT_SECRET=<BigCommerce Customer Token App Client Secret>
# BigCommerce Store 1 setup
BC_CLIENT_ID1=<store 1 oauth client id>
BC_ACCESS_TOKEN1=<store 1 oauth access token>
BC_STORE_HASH1=<store 1 bigcommerce store hash>
BC_PRODUCT_CACHE_TIMEOUT_SECONDS1=<store 1 product cache timeout in seconds>
# BigCommerce Store 2 setup
BC_CLIENT_ID2=<store 2 oauth client id>
BC_ACCESS_TOKEN2=<store 2 oauth access token>
BC_STORE_HASH2=<store 2 bigcommerce store hash>
BC_PRODUCT_CACHE_TIMEOUT_SECONDS2=<store 2 product cache timeout in seconds>
# Continue with as many stores as you wish using the naming convention above incrementing the trailing number
# in each environment variable.
A MySQL Pool client exists in ./db/pool.js
and can be shared across different database files. The intent
was to create a single PoolManager (client) and then load/init that file where it is used. The products-service.js
file has an example of this being loaded at the top, based on an environment variable
named DB_NAME
existing.
DB_HOST=localhost:3306
DB_USER=datase_user_name
DB_PASS=database_user_password
DB_NAME=default_schema
Unix sockets are used to create the connection. GCP Documentation Here
The CLOUD_SQL_CONNECTION_NAME
property is listed on the Overview page of the Instance in GCP
CLOUD_SQL_CONNECTION_NAME=project-id:project-region:cloud-sql-instance-name
DB_USER=datase_user_name
DB_PASS=database_user_password
DB_NAME=default_schema
export NODE_ENV=development
npm run start