npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@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: See mST 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 files start.json and testStart.json may exit. start.json is used when npm start is executed, testStart.json is used when npm test is executed. If the files don't exist exampe-start.json is used to create start.json and testStart.json. Additionally example-testStart.json is used when to create testStart.json. The values in example-testStart.json take precedence over the values in example-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 for mIT:
 {
   "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 needed
  • mIDNeeded: if the service has mID as a target
  • locationNeeded: if location translation is needed
  • standAlone: 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:

  1. retrieve the API from swaggerhub
  2. 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:

  1. retrieve the API from swaggerhub
  2. 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:

  1. stand alone
  2. with mST

The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:

  1. retrieve the API from swaggerhub
  2. get an admin token for that service
  3. 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:

  1. retrieve the API from swaggerhub
  2. get an admin token for mST
  3. register the service in mST
  4. register an admin client for that service in mST
  5. get an admin token for that service
  6. get an admin token for mID if needed
  7. 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:

  1. stand alone
  2. with mST

The environment variable STAND_ALONE will select the mode. When in stand alone, the following actions are being performed:

  1. retrieve the API from swaggerhub
  2. get an admin token for that service
  3. 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:

  1. retrieve the API from swaggerhub
  2. get an Admin token for mST
  3. register the service in mST
  4. 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:

  1. stand alone
  2. 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:

  1. retrieve the API from swaggerhub
  2. get an admin token for that service
  3. 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:

  1. retrieve the API from swaggerhub
  2. get an admin token for mST
  3. setup the customer in mST
  4. register the service in mST
  5. register an admin client for that service in mST
  6. get an admin token for that service
  7. get an admin token for mID if needed
  8. 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:

  1. stand alone
  2. 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:

  1. retrieve the API from swaggerhub
  2. get an admin token for that service
  3. 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:

  1. retrieve the API from swaggerhub
  2. get an Admin token for mST
  3. setup the customer in mST
  4. register the service in mST
  5. 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