platformsh-config
Advanced tools
Comparing version
# Changelog | ||
## [2.4.0] - 2021-02-03 | ||
### Added | ||
* GitHub actions for tests (`quality-assurance.yaml`) and publishing to npm (`npm-publish.yaml`). | ||
### Changed | ||
* `config` method can now get an object `{ varPrefix: string }` to specify a different environment variables prefix. | ||
### Removed | ||
* CircleCI action config. | ||
## [2.3.1] - 2019-11-04 | ||
@@ -4,0 +18,0 @@ |
@@ -27,5 +27,5 @@ 'use strict'; | ||
constructor(env = null, prefix = 'PLATFORM_') { | ||
constructor(env = null, varPrefix = 'PLATFORM_') { | ||
this.environmentVariables = env || process.env; | ||
this.envPrefix = prefix; | ||
this.varPrefix = varPrefix; | ||
@@ -571,3 +571,3 @@ // Node doesn't support pre-defined object properties in classes, so | ||
_getValue(name) { | ||
let checkName = this.envPrefix + name.toUpperCase(); | ||
let checkName = this.varPrefix + name.toUpperCase(); | ||
@@ -624,5 +624,5 @@ return this.environmentVariables[checkName] || null; | ||
*/ | ||
function config() { | ||
function config({ varPrefix } = {}) { | ||
return new Config(); | ||
return new Config(null, varPrefix); | ||
} | ||
@@ -629,0 +629,0 @@ |
{ | ||
"name": "platformsh-config", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "Helper for running nodejs applications on Platform.sh", | ||
@@ -5,0 +5,0 @@ "main": "lib/platformsh.js", |
# Platform.sh Config Reader (Node.js) | ||
 | ||
This library provides a streamlined and easy to use way to interact with a Platform.sh environment. It offers utility methods to access routes and relationships more cleanly than reading the raw environment variables yourself. | ||
@@ -109,2 +111,9 @@ | ||
By default, Platform.sh environment variables are prefixed with `PLATFORM_`. In some cases, you might need to change this default in order to have access to environment variables at build time (like with [create-react-app](https://create-react-app.dev/docs/adding-custom-environment-variables/)). | ||
You can do this like so: | ||
```js | ||
const config = require("platformsh-config").config({ varPrefix: "MY_PREFIX_" }); | ||
``` | ||
### Reading service credentials | ||
@@ -111,0 +120,0 @@ |
Sorry, the diff of this file is not supported yet
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
35635
5.91%8
33.33%195
4.84%1
Infinity%