Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngx-envconfig

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngx-envconfig - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

9

package.json
{
"name": "ngx-envconfig",
"version": "1.0.8",
"version": "1.1.0",
"description": "Configuration utility for Angular based on the environment variables ",

@@ -27,5 +27,6 @@ "repository": {

"peerDependencies": {
"@angular/common": ">=5.0.0 <6.0.0",
"@angular/core": ">=5.0.0 <6.0.0",
"@angular/platform-browser-dynamic": ">=5.0.0 <6.0.0"
"rxjs": "^5.5.2",
"@angular/common": ">=4.0.0 <7",
"@angular/core": ">=4.0.0 <7",
"@angular/platform-browser-dynamic": ">=4.0.0 <7"
},

@@ -32,0 +33,0 @@ "main": "./bundles/core.umd.js",

@@ -15,5 +15,4 @@ # ngx-envconfig

- `ng build --env=dev` builds for development environment. This is the default if you don't specify env value.
- `ng build --env=staging` builds for staging environment.
- `ng build --env=prod` builds for production environment.
- `ng build --configuration=staging` builds for staging environment. For older versions `ng build --env=staging`
- `ng build --configuration=production` builds for production environment. For older versions `ng build --env=prod`

@@ -29,8 +28,38 @@

- **.get(propertyName: string): any**. Returns the corresponding value of the provided property `propertyName` config file.
```javascript
constructor(private config: ConfigService){
console.log(this.config.get('HOST_API'))
// prints: 'http://development.server.com' in development mode
}
```
- **.getEnv(): string**. Returns the current environment
```javascript
constructor(private config: ConfigService){
console.log(this.config.getEnv())
// prints: 'development' in development mode
}
```
- **.isDevMode(): boolean**. Returns `true` if environment is development, otherwhise `false`
```javascript
constructor(private config: ConfigService){
console.log(this.config.isDevMode())
// prints: true in development mode
}
```
- **.getApi(endpoint: string): string**. This function will only work if you have provided `"API_ENDPOINTS"` object in cofig file, which provides the list of available API endpoints and `"HOST_API"` which is the API's host URL. Returns API endpoint from `"API_ENDPOINTS"` by concatenating it with `"HOST_API"`.
```javascript
constructor(private config: ConfigService){
console.log(this.config.getApi('USER'))
// prints: 'http://development.server.com/api/v1/user' in development mode
}
```
- **.onLoad: AsyncSubject<boolean> boolean**. Async subject to be subscribed. Emits when the config file is already loaded.
```javascript
constructor(private config: ConfigService){
this.config.onLoad.subscribe(()=>{
console.log('Config file is loaded');
})
}
```
## Getting Started

@@ -121,4 +150,36 @@

- Add the following snippet to `.angular-cli.json` file.
- Add *staging* configurations in `angular.json` file. Make sure *production* configuration is added.
Default one we assume is the *development* configuration, which is points to `environment.ts` file.
```json
...
"projects": {
"YOUR APP NAME": {
"root": "",
...
"architect": {
"build": {
...
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
...
},
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
]
}
...
}
```
- If you have older version of Anuglar then make the updates in `.angular-cli.json` file as follows:
```json
"environmentSource": "environments/environment.ts",

@@ -125,0 +186,0 @@ "environments": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc