Build your own Shaq bot with Nodered!
- Clone the project
- Install dependencies:
npm install && cd nodered && npm install && cd .. - Run:
NODE_ENV='dev' INSTANCES='SHAQID' CREDENTIAL="..." SEMATEXT="..." PORT=1880 npm start - Go Node-RED admin page with http://localhost:1880/nodered/ for breaking things (default access is admin/password)
- Use webservice with http://localhost:1880/api as base URL
- Have fun
Basic running command: env NODE_ENV='dev' INSTANCES='SHAQID' PORT=1880 npm start
NODE_ENV environment variable is mandatory for loading config file stored at the root directory of this project. By default we provide 3 configuration environments: dev, test and prod that will load respectivelly the file config_dev.json, config_test.json and config_prod.json.
There are another environment variables for setting project options. You can add another environment variables like this: env PASSWORD='$2b$08$mERTOjDUSwijQo5cFLuT0eBaCZ/Kvnv4eOisOqahm.WDAuQ3Hrv4S' ENV='test' PORT=1880 DISABLE_EDITOR=1 ENABLE_PROJECT=0 npm start
NODE_ENV: mandatory, the configuration environment. Can bedev,testandprod.INSTANCES: mandatory, the list separate with comma of Shaq instance code to listen on.CREDENTIAL: mandatory, the list separate with comma of Shaq instance code base64 credential to listen on.SHAQ_URL_PATTERN: the Shaq URL pattern. default tohttps://%USERCODE%.shaq.eu.yoctu.solutions. The pattern can content a mask%USERCODE%that will be replace iteratively by theINSTANCESsetting.SEMATEXT: the Sematext base URL for logging purpose. If not present no log will be send to SematextPORT: the TCP port that service listen.80by default.DISABLE_EDITOR: set to1disable the Node-RED editor,0to enable.0by default.ENABLE_PROJECT: set to1enable project in the Node-RED instance,0to disable.0by default.PASSWORD: set the Nodre-RED editor password. Creadentials areadmin/passwordby default.
If AUTH0_DOMAIN env variable is set so Auth0 integration will be use for user authentication:
AUTH0_DOMAIN: Auth0 application DomainAUTH0_CLIENTID: Auth0 application Client IDAUTH0_CLIENTSECRET: Auth0 application Client SecretAUTH0_CALLBACKURL: Callback URL where Auth0 redirect the user to the nodered instance
User must have the user_metadata https://shaq.yoctu.solutions/nodered set to 1 in order to be credential.
The prod environment config file:
TODO
- Run the project:
NODE_ENV='dev' INSTANCES='SHAQID' CREDENTIAL="..." SEMATEXT="..." PORT=1880 npm start - Open http://localhost:1880/api.html (TODO)
- Run the project with the Node-RED editor activated and modify flows.
- Test, test and test and test
- Commit your change on
developbranch (or do a pull request ondevelopbranch with Github)
We use Jest as testing framework and we maintain functional tests.
For running tests:
- run the project with
NODE_ENV='dev' INSTANCES='SHAQID' CREDENTIAL="..." SEMATEXT="..." PORT=1880 npm start - run tests with
env PORT=1880 npm run test
All new features must have functionnal tests.
- build
docker build -t project_name . - run
docker run -e NODE_ENV='dev' -e PORT=1880 -e INSTANCES='SHAQID' -e CREDENTIAL="..." -e SEMATEXT="..." -p 8080:1880 project_name:latest
TODO