@mimik/local
v6.0.13
Published
Local setup configuration for normal and test opreration
Downloads
109
Readme
local
Set of function for local deployment.
The following files are expected to exist:
In the directory above the server root directory: mSTConfig.json
, mIDConfig.json
, mITConfig.json
,sumoLog.json
, kinesisLog.json
, s3Log.json
, customerConfig.json
, key.json
, locationConfig.json
are being set. If they don't exist at the launch of the script, default will be setup.
- for
mSTConfig.json
:
{
"basePath": "base path of the mST server, for example: `/mST/v1`",
"protocol": "protocol for the mST server, for example: `http:`, by default `http:`",
"domainName": "domain name of the mST server",
"port": "port for the mST server, for example: `8025`",
"passphrase": "passphrase to be used to generate public private key pair, if not present mST will user regular key",
"update": "switch to indicate if mST needs to be updated, default is `false`. If the address is localhost, mST will be updated"
"admin": {
"clientId": "id or the client in order to get an admin token for mST, for example: `12345`",
"clientSecret": "secret of the client in order to get an admin token for mST, for example: `timeForSecret`"
}
}
domainName
must exit, and when domainName
is equal to localhost
, port
must exist. When domainName
is equal to localhost
the local ip
will replace localhost
. When domainName
is different of localhost
the port
will be ignored.
- for
mIDConfig.json
:
{
"basePath": "base path of the mID server, for example: `/mID/v1`",
"protocol": "protocol for the mID server, for example: `http:`, by default `http:`",
"domainName": "domain name of the mID server",
"port": "port for the mST server, for example: `8015`",
"implicit": {
"key": "a key to sign and verify the signature of a use token: `timeForSecret`",
"audience": "url defining the audinece used in user token: `https://mimik`"
}
}
Similar properties than for mSTConfig on domainName
and port
apply.
- for
mITConfig.json
:
{
"basePath": "base path of the mIT server, for example: `/mIT/v1`",
"protocol": "protocol for the mIT server, for example: `http:`, by default `http:`",
"domainName": "domain name of the mIT server",
"port": "port for the mIT server, for example: `8050`"
}
Similar properties than for mSTConfig on domainName
and port
apply.
- for
sumoLog.json
:
{
"<serverType>": {
"url": "base URL for sumologic, for example: `https://endpoint2.collection.us2.sumologic.com/receiver/v1/http/`",
"code": "code for sumologic, everything after the last / in the sumologic URL"
},
"default": {
"url": "base URL for sumologic, for example: `https://endpoint2.collection.us2.sumologic.com/receiver/v1/http/`",
"code": "code for sumologic, everything after the last / in the sumologic URL"
}
- for
kinesisLog.json
:
{
"region": "region of the Kinesis implementation",
"accessKeyId": "access key id of Kinesis",
"secretAccessKey": "secret access key for Kinesis",
"streamNameInfo": "name of the kiniesis stream for info",
"streamNameError": "name of the kiniesis stream for error",
"streamNameOther": "name of the kiniesis stream for all the other levels"
}
- for
s3Log.json
:
{
"region": "region of the S3 implementation",
"accessKeyId": "Access key id for S3",
"secretAccessKey": "secret access key for S3",
"bucketname": "name of the S3 bucket used to store the information",
"maxEvents": "number of events buffered before sending to S3 (integer)",
"timeout": "number of seconds before timeout to send to S3 (integer)",
"maxSize": "max size in Bytes before sending to S3 (integer)"
}
- for
key.json
:
{
"bitbucket": {
"username": "username to access the bitbucket account",
"password": "password to access the bitbucket account"
},
"swaggerhub": "key to access private API on swaggerhub"
}
- for
locationConfig.json
:
{
"url": "url of the location provider"
"key": "key to make request to the location provider"
}
A property may be defined for each serverType
involved. If the serverType does not exist the default will be picked.
- for
customerConfig.json
: SeemST
README.md
file for an example of a customer configuration. This may have to be updated to reflect the new servers. - in the
local
directory of the server root directory: two filesstart.json
andtestStart.json
may exit.start.json
is used whennpm start
is executed,testStart.json
is used whennpm test
is executed. If the files don't existexampe-start.json
is used to createstart.json
andtestStart.json
. Additionallyexample-testStart.json
is used when to createtestStart.json
. The values inexample-testStart.json
take precedence over the values inexample-start.json
. The configuration of these files depends on the configuration parameters of the server. If the files The following is an example of start.json file formIT
:
{
"NODE_ENV": "local",
"LOG_LEVEL": "debug",
"CONSOLE_LEVEL": "silly",
"DATABASE_NAME": "itResources",
"SERVER_PORT": 8050,
"IP_LOCATION_PROVIDER": "http://localhost:9000/json",
// "LOCATION_PROVIDER": "http://ip-api.com/json",
// "DEBUG": "swagger-tools:middleware.*",
"SERVER_SECURITY_SET": "off"
}
While all the files use the .json
extension it is still possible to add comments //
in the file to make the file more explicit or to remove some parameters.
There are reserved environement variable used by the library for configuration:
oauthImplicitNeeded
: if the service handles user token the implicit configuration is neededmIDNeeded
: if the service has mID as a targetlocationNeeded
: if location translation is neededstandAlone
: if the service need to be operated without other service. If the service has targets most likely 500 errors will be generated
If SERVER_ID is not set in the start.json or testStart.json file, SERVER_ID will be assigned with a uuid.v4.
For test in json file (server-test.json
) is created in .
.
This file contains informations needed to start the test:
{
"start": "information needed to setup the environement variable for the test",
"CUSTOMER_NAME": "name of the customer to setup customer config",
"CUSTOMER_CODE": "code of the customer to setup coustomer config, `not available for MST`",
"BASE_PATH": "base path of the API",
"MST_TOKEN": "mST admin token for creating clients, `no available in standAlone`",
"ADMIN_TOKEN": "admin token of the service, `no available in standAlone`",
"MID_TOKEN": "mID admin token for creating users when `authImplicitNeeded is set, `not available in standAlone`")
}
In standAlone mode the test can easily get the token using oauth-helper-temp
.
Example
const local = require('@mimik/local');
local~mSTTestSetup() ⇒
Setup mST for test.
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
The following actions are being performed:
- retrieve the API from swaggerhub
- generate a json object stored in a file in . to enable the test
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumoLog.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ./local/testStart.json
| The local configuration. If it does not exist start.json and if sart.json does not exist start-example.json will be used to create start.json
Category: sync
local~mSTSetup() ⇒
Setup mST.
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
The following actions are being performed:
- retrieve the API from swaggerhub
- generate a shell script in a file in . to start the server
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumoLog.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ./local/start.json
| The local configuration. If it does not exist start-example.json will be used to create start.json
Category: sync
local~testSetup() ⇒
Setup mIT for test.
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
Two modes are available:
- stand alone
- with mST
The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for that service
- generate a json object store in a file under .
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
When mST and other servers are present, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for mST
- register the service in mST
- register an admin client for that service in mST
- get an admin token for that service
- get an admin token for mID if needed
- generate a json object store in a file under .
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumoLog.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ./local/testStart.json
| The local configuration. If it does not exist start.json and if sart.json does not exist start-example.json will be used to create start.json
Category: sync
local~setup() ⇒
Setup mIT.
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
Two modes are available:
- stand alone
- with mST
The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for that service
- generate a shell script to start the server
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
When mST is present, the following actions are being performed:
- retrieve the API from swaggerhub
- get an Admin token for mST
- register the service in mST
- generate a shell script to start the server
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumoLog.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ./local/start.json
| The local configuration. If it does not exist start-example.json will be used to create start.json
Category: sync
local~testSetup() ⇒
Setup a service (not mST, mIT) for test.
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
Two modes are available:
- stand alone
- with mST, mID are other dependent servers
The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for that service
- generate a json object store in a file under .
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
When mST and other servers are present, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for mST
- setup the customer in mST
- register the service in mST
- register an admin client for that service in mST
- get an admin token for that service
- get an admin token for mID if needed
- generate a json object store in a file under .
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumoLog.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ../mIDConfig.json
| The config for mID
| ../customerConfig.json
| The mST customer config
| ./local/testStart.json
| The local configuration. If it does not exist start.json and if sart.json does not exist start-example.json will be used to create start.json
Category: sync
local~setup() ⇒
Setup a service (not mST, mIT).
Kind: inner method of local
Returns: null
.
Will exit 1 if there is an error.
Two modes are available:
- stand alone
- with mST, mID are other dependent servers
The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:
- retrieve the API from swaggerhub
- get an admin token for that service
- generate a shell script to start the server
In standAlone the dependencies will not be reachable and the operation that implies reaching dependencies will most likely generate a 500 error
When mST and other servers are present, the following actions are being performed:
- retrieve the API from swaggerhub
- get an Admin token for mST
- setup the customer in mST
- register the service in mST
- generate a shell script to start the server
The following files are needed to perform these actions:
| Filename | Description |
| -------- | ----------- |
| ../sumo.json
| The sumologic endpoints and code
| ../kinesisLog.json
| The Kinesis information
| ../s3Log.json
| The S3 information
| ../mSTConfig.json
| The config for mST
| ../mITConfig.json
| The config for mIT
| ../mIDConfig.json
| The config for mID
| ../customerConfig.json
| The mST customer config
| ./local/start.json
| The local configuration. If it does not exist start-example.json will be used to create start.json
Category: sync