Configuration
The main steps needed to customize the project according to your own business logic are listed below; in addition the project contains some TODO
comment in order to highlight the necessary steps to customize the service.
Environment Variables
The table below shows the environment variables that are used by this service.
Variable name | Variable type | Description |
---|---|---|
MODEFINANCE_BASE_URL | string (required) | Base URL for the Modefinance APIs |
MODEFINANCE_CLIENT_ID | string (required) | Client ID to access Modefinance APIs |
MODEFINANCE_CLIENT_SECRET | string (required) | Client secret to access Modefinance APIs |
ROUTER_URL | string (required) | Base URL for the Flow Manager Router service |
MAX_RETRIES | int (required) | Max retries to perform in case of http call |
RETRIES_DELAY_MS | int (required) | Delay between retries in milliseconds |
MODE | string (default = REST) | Service working mode. REST or KAFKA |
KAFKA_CONFIG_FILE_PATH | string (optional) | Path to the file with Kafka configuration |
The Platform variables USERID_HEADER_KEY
, GROUPS_HEADER_KEY
, CLIENTTYPE_HEADER_KEY
, BACKOFFICE_HEADER_KEY
, MICROSERVICE_GATEWAY_SERVICE_NAME
are also required.
Kafka
Kafka can be enabled setting the MODE
variable to KAFKA
, in this case the KAFKA_CONFIG_FILE_PATH
variable is required and REST endpoint is disabled.
The configuration has the following schema:
{
"type": "object",
"required": [
"clientId",
"brokers",
"authMechanism",
"username",
"password",
"consumerConfig",
"producerConfig",
],
"properties": {
"clientId": { "type": "string"},
"brokers": { "type": "string"},
"authMechanism": { "type": "string"},
"username": { "type": "string"},
"password": { "type": "string"},
"connectionTimeout": { "type": "number"},
"authenticationTimeout": { "type": "number"},
"connectionRetries": { "type": "number"},
"consumerConfig": {
"type": "object",
"required": [
"groupId",
"topic",
],
"properties": {
"topic": { "type": "string" },
"groupId": { "type": "string" },
"sessionTimeout": { "type": "number" },
"rebalanceTimeout": { "type": "number" },
"heartbeatInterval": { "type": "number" },
"allowAutoTopicCreation": { "type": "boolean" },
},
},
"producerConfig": {
"type": "object",
"required": [
"topic",
],
"properties": {
"topic": { "type": "string" },
"allowAutoTopicCreation": { "type": "boolean" },
},
},
},
}
Refer to KafkaJS for the configuration meanings.
Service Logic
In order to customize the identification logic or integrate an external identification service you can modify the following files:
/src/lib/service.ts
: contains custom identification logic/src/restHandlers/service.ts
and/src/kafkaHandlers/service.ts
: contains service handlers/src/clients/modefinanceClient.ts
: contains the logic to perform calls to external service
Process Data
Data extracted can be modified before send them to main flow manager.
In particular, a mapping function, defined in /src/services/mainFlowDataMapping.ts
, is applied by default in order to manipulate the extracted data.