5.0.12 • Published 2 months ago

@mimik/configuration v5.0.12

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
2 months ago

configuration

Example

const config = require('@mimik/configuration');

configuration~isProd() ⇒ boolean

Indicates if the environment is prod

Kind: inner method of configuration
Returns: boolean - true if the environment is prod or production.

The following environment variables are used

Env variable nameDescriptionValueComments
NODE_ENVenvironnment of the microservice

Category: sync

configuration~setConfig(pack, options) ⇒ object

Set the configuration of the micro-service.

Kind: inner method of configuration
Returns: object - The configuration.
Category: sync
Throws:

  • configuration.serverSettings.type Will trow an error if a mandatory value is missing.

The following environment variables are being setup:

Env variable nameDescriptionValueComments
SERVER_VERSIONversion of the software for the micro-servicepackage.versionserverSettings.version
SERVER_NAMEname of the micro-servicepackage.nameserverSettings.name
SERVER_TYPEtype of the micro-servicepackage.mimik.typeserverSettings.type
SWAGGER_FILE_VERSIONversion of the swagger file for the APIpackage.swaggerFile.versionserverSettings.swaggerFile.version
SWAGGER_FILE_ACCOUNTaccount associated with the APIpackage.swaggerFile.accountserverSettings.swaggerFile.account
SWAGGER_FILE_NAMEname of the APIpackage.swaggerFile.nameserverSettings.swaggerFile.name
SWAGGER_FILE_PROVIDERprovider of the API filepackage.swaggerFile.providerserverSettings.swaggerFile.provider, if not present the default is bitbucket
SERVER_LOCAL_IPV4IP address of the micro-serviceip.address()serverSettings.ip.local
CONSOLE_LEVELlog level for console outputdebuglogInfo.consoleLevel
LOG_LEVELlog level for console outputdebuglogInfo.logLevel
AWS_LOCAL_PROPERTIESinternal ip address to access aws instance properties169.254.169.254
MST_SETto setup configuration without mST and oauth token setuponon/off

The following environement variables are being used for the configuration:

Env variable nameDescriptionDefaultConfig propertyComments
NODE_ENVrunning environmentlocalnodeEnvironment
LOCATION_PROVIDERlocation provider URL to use for ip location or noPublic or environmentnoPubliclocationProvider.url or locationProvidersee public-helper
LOCATION_PROVIDER_KEYlocation provider key to use to access the location providernulllocationProvider.keysee public-helper
CLOUD_PROVIDERcloud provider running the servicenoCloudcloudProvidersee public-helper
SERVER_IDservice iduuid.v4()serverSettings.id
CUSTOMER_CODEcustomer code associated with the service instance''serverSettings.customerCodeempty string
SWAGGER_FILE_DIRECTORYdirectory where the api definition is located./apiserverSettings.api1
BITBUCKET_USERNAMEusername to access bitbucket read access on the swagger repos' 'serverSettings.apiBasicAuth.username
BITBUCKET_PASSWORDpassword to access bitbucket read access on the swagger repos' 'serverSettings.apiBasicAuth.password
SWAGGERHUB_API_KEYapiKey to access swaggerhubserverSettings.apiApiKey
SERVER_SECURITY_SETswitch to enable or disable the token interpretationonserverSettings.securitySetonly active if environment is local
INTERCEPT_ERRORswitch to use or not the errorIntercept optiononserverSettings.interceptErrormust be set to off for mID
SERVER_PORTport of the serverserverSettings.port
SERVER_PUBLIC_PROTOCOLprotocol used to defined the domain address of the sevicehttp:serverSettings.public.protocol
SERVER_PUBLIC_DOMAIN_NAMEdomain name used to define the domain address of the servicenullserverSettings.public.domainName
ADMIN_EXTERNAL_IDexternal id of the admin role to be chacked in the tokenadminsecurity.admin.externalId
OAUTH_CLIENT_IDsecurity id of the servicesecurity.server.id2
OAUTH_CLIENT_SECRETsecret of the servicesecurity.server.secret2
OAUTH_CLIENT_ACCESS_KEYkey for token signaturesecurity.server.accessKey2
OAUTH_CLIENT_AUDIENCEurl representing the server to mSTsecurity.server.audience2
OAUTH_ISSUERtoken url of mSTsecurity.server.issuer2
OAUTH_GENERIC_KEYkey for token signature provided when a generic for this service type is definednoGenericsecurity.generic.key2
OAUTH_GENERIC_PREVIOUS_KEYkey for the token signature before change the public keysecurity.generic.previousKey2
OAUTH_GENERIC_AUDIENCEurl representing the generic of the service type to mSTnoGenericsecurity.generic.audience2
API_KEYSlist of API Keys which a test against in case of APIKey security[]
LOG_MODEcollector the be used to log eventssumologiclogInfo.modecan be sumologic, awsS3, all, 'awsKinesis'
NO_STACKdisable the inclusion of a the stack in all logsyeslogInfo.noStack
FILTER_FILEpath for the filter file definitionnulllogInfo.filterFile
USER_DEFINITIONS_FILEpath for the custom user definitionsnulluserDefinitions.file
EXIT_DELAYdelay to allow the log transports to flush2000logInfo.exitDelayin milliseconds
CLUSTER_MANAGEMENTswitch to enable cluster communicationoffcluster.managementcan be on or off
REQUEST_TIMEOUTtimeout for intra cluster http request10000cluster.timeoutin milliseconds
CACHE_SETswitch to enable use of cacheoffcache.setcan be on, off
TOPIC_SETswitch to enable use of event topicofftopic.setcan be on, off, mock
SET_SNS_TOPIC_FIFOset to yes if fifo topicnotopic.isFifoTopiccan be yes, no
SET_SNS_CONTENT_DEDUPLICATIONset to yes, to use content based deduplicationnocontentBasedDeduplicationwhen fifo topic is used and set to no, MessageDeduplicationId must be provided in message.
ENCRYPTION_SETswitch to enable use of mongodb encryptionoffencryption.setcan be on, or off
MIT_URLurl for reaching mITdependencies.mIT.url
MIT_AUDIENCEaudience of mITdependencies.mIT.audience2
REGISTRATION_SETswicht to enable user of registrationonregistration.setcan be on or off
REGISTRATION_RETRYretry time for registering to mIT3000registration.retryin milliseconds
$_URL.toUpperCase()cluster informationselfdependencies.(SERVER_TYPE).urlshould not be used
${configuration.serverSettings.type}_AUDIENCE.toUpperCase()cluster informationdependencies.(SERVER_TYPE).audience2, but should not be used

1: /(SWAGGER_FILE_ACCOUNT)_(SERVER_TYPE)_(SWAGGER_FILE_VERSION)_swagger.json is added to the serverSettings.api property

2: defined when registering to mST

When MST_SET is off, registration and cluster should not be enabled, so configuration.cluster.management and configuration.registration.set will be set to `off

When sumologic or all is used for LOG_MODE the following environment variables are used for the configuration:

Env variable nameDescriptionDefaultComments
SUMO_LOGIC_ENDPOINTendpoint of the sumologic collector to used for logs
SUMO_LOGIC_COLLECTOR_CODEid of the collector in sumologic

When awsS3 or all is used for LOG_MODE the following environment variables are used for the configuration:

Env variable nameDescriptionDefaultComments
S3_AWS_ACCESS_KEY_IDaccess key id for AWS S3
S3_AWS_SECRET_ACCESS_KEYsecret access key for AWS S3
S3_AWS_BUCKET_NAMEname of the bucket used in S3
S3_AWS_REGIONregion where the bucket is
S3_AWS_TIMEOUTmaximum time a log can stay before being sent to S35in minutes
S3_AWS_MAX_SIZEmaximum size of the block of logs before being sent to S35in mB
S3_AWS_MAX_EVENTSmaximum number of logs to be in the block before being sent to S31000

When on is used for TOPIC_SET the following environment variables are used for the configuration:

Env variable nameDescriptionDefaultComments
SNS_AWS_ACCESS_KEY_IDaccess key id for AWS SNS
SNS_AWS_SECRET_ACCESS_KEYsecret access key for AWS SNS
SNS_AWS_REGIONregion where the topic is----noRegion----

When a database is involved | Env variable name | Description | Default | Comments | | DATABASE_CONNECTION_TIMEOUT | the time to connect to the database before error is generated | 30 | in seconds | DATABASE_VALIDATION_CHECK | the delay before checking for connection | 1000 | in ms | DATABASE_RECONNECTION_OFFSET | offset for the time to reconnect to the database before error is generated | 5 | in seconds

When mongodb is used the following environment variables are used for the configuration:

Env variable nameDescriptionDefaultComments
DATABASE_NAMEname of the database to store the information
DATABASE_IPip address of the databaselocalhost
DATABASE_USERuser to access the databasenullif missing no user/password will be used
DATABASE_PASSWORDpassword to access the databasenullif missing no user/password will be used
MONGO_USE_SRVto use srv connection url set to yesno
MONGO_AUTH_DATABASEthe auth database where users exists
MONGO_MAX_POOL_SIZEthe minimum number of connections in the connection pool5
MONGO_MIN_POOL_SIZEthe maximum number of connections in the connection pool10
MONGO_MAX_IDLE_TIMEthe maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed3000in milliseconds
MONGO_RETRY_WRITESdefines if the transaction should be tried again to write set to true or false
MONGO_WRITE_CONCERNaccepts a number or majority
MONGO_SSLuses ssl connection if yesno
MONGO_SSL_VALIDATEvalidates mongod server certificate against ca if set to yesyesyes if MONGO_SSL is also yes
MONGO_SSL_ALLOW_INVALID_HOSTNAMESset to yes to allows invalid hostnames
MONGO_REPLICAT_SETspecifies the name of the replica set, if the mongod is a member of a replica setnot mandatory
MONGO_WAIT_QUEUE_MULTIPLEa number that the driver multiples the maxPoolSize value to, to provide the maximum number of threads allowed to wait for a connection to become available from the poolno mandatory
MONGO_WAIT_QUEUE_TIMEOUTthe maximum time in milliseconds that a thread can wait for a connection to become availablenot mandatory
MONGO_SOCKET_TIMEOUTThe time in milliseconds to attempt a send or receive on a socket before the attempt times out20000in milliseconds
MONGO_FAMILYIP address family44 -> IPV4, 6 -> IPV6
MONGO_SERVER_SELECTION_TIMEOUTthe MongoDB driver will try to find a server to send any given operation to, and keep retrying for serverSelectionTimeoutMS milliseconds30000in milliseconds
MONGO_HEARTBEAT_FREQUENCYthe MongoDB driver sends a heartbeat every heartbeatFrequencyMS to check on the status of the connection10000in milliseconds

When on is used for ENCRYPTION_SET the following environment variables are used for the configuration:

Env variable nameDescriptionDefaultComments
ENCRYPTION_DATABASEdatabase name where data encryption keyvault existsadmin
KEY_VAULT_TABLEcollection name which has data encryption keyskeystore
KMS_PROVIDERKey Management service provider for master keylocal
MASTER_KEY_AWS_REGIONif KMS is aws region where master key exists----noRegion----
MASTER_KEY_ARNif KMS is aws ARN of master key
ENCRYPTION_ACCESS_KEY_IDif KMS is aws, accessKeyId to connect KMS
ENCRYPTION_SECRET_ACCESS_KEYif KMS is aws, secretAccessKey to connect KMS
LOCAL_MASTER_KEYif KMS is local, masterkey to encrypt data keys

When dynamodb is used the following environement variables are used for the configuration:

Env variable nameDescriptionDefaultComments
DYNAMODB_AWS_ACCESS_KEY_IDaccess key id for AWS dynamodb
DYNAMODB_AWS_SECRET_ACCESS_KEYsecret access key for AWS dynamodb
DYNAMODB_AWS_REGIONregion where dynamodb is----noRegion----
DYNAMODB_LOCAL_URLurl access the locally deploy dynamodbhttp://localhost:8000
DYNAMO_THROUGHPUT_READthroughput read for dynamodb index1
DYNAMO_THROUGHPUT_WRITEthroughput write for dynamodb index1
DYNAMO_SCHEMA_THROUGHPUT_READthroughput read for dynamodb schema1
DYNAMO_SCHEMA_THROUGHPUT_WRITEthroughput write for dynamodb schema1
DYNAMO_SCHEMA_THROUGHPUTthroughput for dynamodb schema

DYNAMO_SCHEMA_THROUGHPUT takes precedence over DYNAMO_SCHEMA_THROUGHPUT_READ and DYNAMO_SCHEMA_THROUGHPUT_WRITE. If DYNAMO_SCHEMA_THROUGHPUT is set to ON_DEMAND then index throughput wont apply, and if DYNAMO_SCHEMA_THROUGHPUT is not set to a number the value will be 1.

When redis is used the following environement variables are used for the configuration:

Env variable nameDescriptionDefaultComments
CACHE_IPdomain of the redis server to use with port, a comma seperated list if using clusterlocalhost:6379
CACHE_USERredis user if the redis service is auth protectednull
CACHE_PASSWORDredis password for the user if the redis service is auth protectednull
CACHE_CLUSTER_SETset on, when using redis in a cluster.off
CACHE_CLUSTER_USE_REPLICASWhen set on, distribute load by executing readonly commands (such as GET) across all cluster nodes. When false, only use master nodesoff
CACHE_CLUSTER_MINIMIZE_CONNECTIONWhen set on, .connect() will only discover the cluster topology, without actually connecting to all the nodes. Useful for short-term or Pub/Sub-only connections.off
CACHE_CONNECTION_TIMEOUTtime the server will wait at start to connect to the cache30in seconds
CACHE_VALIDATION_CHECKthe delay before checking for connection1000in ms
CACHE_RECONNECTION_OFFSEToffset for the time to reconnect to the database before error is generated5in seconds
CACHE_REQUEST_TTLrequest time to live in cache10in seconds
CACHE_API_ID_TTLAPI request time to live for main resource20in seconds
CACHE_API_OPTION_TTLAPI request time to live for option5in seconds
REDIS_RECONNECT_TRIESnumber of tries to restablish a connection100
REDIS_RECONNECT_INTERVALtime to wait before retry500in milliseconds
REDIS_REQUEST_MAX_MEMORYmaximum memory size of the request cache10in megabytes
REDIS_REQUEST_MAX_MEMORY_POLICYeviction policy of the request cacheallkeys-lru
REDIS_SOCKET_KEEPALIVEkeep long running connections alive for x seconds5000in seconds
REDIS_DISABLE_OFFLINE_QUEUEqueuing event when not connectedno

Requires: module:@mimik/sumologic-winston-logger

ParamTypeDescription
packstringPackage.json object to use for the configuration.
optionsobjectOptions to add to the config.
5.0.12

2 months ago

5.0.10

4 months ago

5.0.11

4 months ago

5.0.9

5 months ago

5.0.6

8 months ago

5.0.8

5 months ago

5.0.7

7 months ago

5.0.5

12 months ago

5.0.4

1 year ago

5.0.3

1 year ago

5.0.2

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

4.4.13

1 year ago

4.4.12

1 year ago

4.4.11

1 year ago

4.4.10

2 years ago

4.4.9

2 years ago

4.4.8

2 years ago

4.4.5

2 years ago

4.4.4

2 years ago

4.4.7

2 years ago

4.4.6

2 years ago

4.4.3

2 years ago

4.4.2

2 years ago

4.4.1

2 years ago

4.4.0

2 years ago

1.4.1

4 years ago

1.4.0

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago