4.4 KiB
This repo contains tools to help run a local version of node_server.
This is ideal for development and local testing without interfering with any of the servers.
To Use
- For mongo and minio, install Virtual Box.
- For mongo and minio, install Vagrant.
- Follow the steps in
mongodb\README.md
to install and run a local mongodb - Follow the steps in
nginx\README.md
to install and run a local nginx proxy - Follow the steps in
minio\README.md
to install and run a local minio serverr - Set the environment for the node server appropriately for the local setup (see below)
- Run your local dev server as (see below)
Running local dev server
To run a local debug server you need to (after installing the support tools as above):
- Install node.js 8.x
- Clone the https://bitbucket.org/comcarde/bridge-node-server repo
- Copy the compiled email templates into
node_server/email_templates/
from either- Get them from from Jenkins http://10.0.10.240:8080/job/Emails%20Build/lastSuccessfulBuild/artifact/bin/
- Build locally by checking out https://bitbucket.org/comcarde/comcarde-server-emails and
gulp compile --production
then copying bin
- Run
npm install
- Set the environment variables up as described below
- Run your server using node (e.g. through your prefered IDE)
- Use
gulp test-watcher --cwd node_server
to run unit tests automatically on each file modification
REQUIRED Local Debug Server environment variable
You will need to set your environment for the local debug node server to match this local setup. All standard environment variables used in the server should be included, but the following values should be modified from the real servers.
Setting | Value | Reason |
---|---|---|
loadbalancer_vip |
localhost |
Used in trust proxy setting in express. Address of the nginx proxy. |
webAddress |
localhost |
The expected hostname for requests, for configuring CORS for the portal, etc. |
mongoUser |
mdbadmin |
As set in the mongodb VM |
mongoPassword |
abc123 |
As set in the mongodb VM |
mongoDBAddress |
@172.16.0.20:27017 |
As set in the mongodb VM |
mongoUseSSL |
true |
The mongodb VM uses SSL |
mongoCACertBase64 |
<certpath>/mongodb.pem |
WARNING: This path is relative to node_server ! Ignore the bad naming, this should point to a PEM file, not a Base64 value! The SSL is encryption only and the CA of the cert is not verified, so any pem file will do. The one from the MongoDB setup is a reasonable one to use for dev. Recommended location is ../../mongodb.pem so it sits outside the git repo and doesn't have to be ignored every commit. |
minioEndpoint |
"172.16.0.21" | Minio local IP |
minioPort |
"9000" | Minio local Port |
minioAccessKey |
"XXXXXXXXXXXXXXXXXXXX" | See /minio/README.md |
minioSecretKey |
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | See /minio/README.md |
minioStorageBucket |
"dev" | Name of Minio bucket |
Other required fields will be notified at startup.
OPTIONAL Debug Server environment
The following optional environment variables can be useful depending on what parts of the server you are wanting to debu
Setting | Value | Reason |
---|---|---|
debug |
core:*,ComServe:* |
Defines which debug() statements in the code to enable. See the debug module on NPM for details |
Optional Code Modifications for local dev
The following code modifications can make it easier to do local development:
Removing HMAC checks
When using Postman or similar to simulate a device and call the commands you want to test, it is easier to disable the HMAC checking (as HMACs are hard to calculate in Postman).
At the top of ComServe/auth.js
-> checkHMAC()
, add:
next(null);
return;
to remove the checks.
Debug the webconsole
If you are debugging the webconsole project, and it's running on http instead of https, you need to change the CORS config or the browser will block your requests.
At the top of swagger_api\api_cors_middleware.js
change:
const ORIGIN_PROTOCOL = 'https';
to:
const ORIGIN_PROTOCOL = 'http';