@dotcom-reliability-kit/app-info
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -46,5 +46,22 @@ const path = require('path'); | ||
/** | ||
* Extract the proceess type from a Heroku dyno name. | ||
* | ||
* @param {string} dyno | ||
* The dyno name to normalize. | ||
* @returns {string} | ||
* Returns the process type of a dyno, e.g. `web` for a dyno called `web.1`. | ||
*/ | ||
function normalizeHerokuProcessType(dyno) { | ||
return dyno.split('.')[0]; | ||
} | ||
const systemCode = | ||
process.env.SYSTEM_CODE || getSystemCodeFromPackage(process.cwd()) || null; | ||
const processType = | ||
process.env.AWS_LAMBDA_FUNCTION_NAME || | ||
(process.env.DYNO && normalizeHerokuProcessType(process.env.DYNO)) || | ||
null; | ||
module.exports = { | ||
@@ -104,3 +121,11 @@ /** | ||
*/ | ||
systemCode | ||
systemCode, | ||
/** | ||
* The dyno process type. | ||
* | ||
* @readonly | ||
* @type {string | null} | ||
*/ | ||
processType | ||
}; | ||
@@ -107,0 +132,0 @@ |
{ | ||
"name": "@dotcom-reliability-kit/app-info", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A utility to get application info in a consistent way.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -13,2 +13,3 @@ | ||
* [`appInfo.systemCode`](#appinfosystemcode) | ||
* [`appInfo.processType`](#appinfoprocesstype) | ||
* [Contributing](#contributing) | ||
@@ -70,3 +71,12 @@ * [License](#license) | ||
### `appInfo.processType` | ||
Get the type of the running process, which is the name for the current process within an application. | ||
For AWS Lambda, this is the name of the function, read from `process.env.AWS_LAMBDA_FUNCTION_NAME`. | ||
For Heroku, this is derived from the first part of `process.env.DYNO`, which is set to by Heroku, e.g. a dyno called `web.1` will have `processType` set to `web`. The process types in an application are defined by the application's `Procfile`. | ||
If neither `process.env.AWS_LAMBDA_FUNCTION_NAME` or `process.env.DYNO` are set, this property will be `null` | ||
## Contributing | ||
@@ -73,0 +83,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8057
119
89
3
1
14
1