synflows-crm v16.13.2
Synflows CRM REST API
Introduction
This API, written in node.js using the Hapi framwork ( https://hapi.dev/ ), is used to store people and their products within the Synflows Platform.
This Api is following the Synflows Api Guidelines: https://dev.azure.com/Synflows/Synflows%20development/_wiki/wikis/Synflows-development.wiki/3/Synflows-API-Guidelines
The OpenApi (Swagger) specification can be found at: http://{hostname}:{portnumber}/documentation
Getting Started
Install all dependencies required for the project using the command npm install
.
Run database migrations
npm run db:migrate
Compiles and hot-reloads for development
npm run dev
Run unit tests
npm run test
Configuration
Make a copy of .env.example
and rename it to .env
. Put here your authorization for launching the project on localhost. This loads only when you run npm run dev
.
Docker
Build the docker image:
docker build -t synflows/crm --build-arg NPM_RC="$(cat ~/.npmrc)" .
Save docker image to a tar file:
docker save -o docker/synflows-crm.docker.tar synflows/crm
Copy docker image to server:
scp docker/synflows-crm.docker.tar waxtrapp@repo.synflows.net:docker-images
Connecting with RabbitMQ
If you want to connect your local dev environment with a RabbitMQ container on another server, you need to establish a SSH-tunnel between the two. On your dev machine start the SSH-connection to the server:
ssh -4 waxtrapp@uhura.synflows.net -L 5672:172.19.0.6:5672 -L 15672:172.19.0.6:15672
With the SSH-tunnel in place, you can connect to ports 5672 and 15672 on localhost. There are three .env settings which allow you to configure the connection to RabbitMQ
IP-address of the RabbitMQ server and credentials to connect:
RMQ_CONNECT=user:password@localhost
Which queues to create at startup. This is only needed once and can be done from receiving side as well. To make sure no messages are lost, you can create the queue before the first message is sent. Multiple queues can be specified using a |-separator:
RMQ_QUEUES=waxtrapp06|theotherqueue
You can include the CRM-data in the message to RabbitMQ. Only supported in a development environment.
RMQ_INCLUDE_DATA=true
Recieved messages
On the target server run the following command to peek at the first message in the queue. This will set the redelivered flag on that message to TRUE:
curl -su 'user:password' -H "content-type:application/json" -X POST http://172.19.0.6:15672/api/queues/%2f/waxtrapp06/get -d'{"count":1,"ackmode":"ack_requeue_true","encoding":"auto","truncate":50000}' | json_reformat
8 months ago