@adonisjs/config
Advanced tools
Comparing version 1.0.10 to 1.0.11
declare module '@ioc:Adonis/Core/Config' { | ||
export interface ConfigContract { | ||
/** | ||
* Get value for a key from the config store | ||
*/ | ||
get(key: string, defaultValue?: any): any; | ||
/** | ||
* Merge values for a key with the default values | ||
*/ | ||
merge(key: string, defaultValues: object, customizer?: Function): any; | ||
/** | ||
* Set value for a key | ||
*/ | ||
set(key: string, value: any): void; | ||
/** | ||
* Define defaults that will be merged with the user defined config. | ||
*/ | ||
defaults(key: string, value: any): void; | ||
@@ -7,0 +19,0 @@ } |
"use strict"; | ||
/* | ||
* @adonisjs/config | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +11,0 @@ const utils_1 = require("@poppinss/utils"); |
/// <reference path="../adonis-typings/config.d.ts" /> | ||
import { ConfigContract } from '@ioc:Adonis/Core/Config'; | ||
/** | ||
* Config module eases the process of using configuration inside your AdonisJs | ||
* applications. | ||
* | ||
* The config files are stored inside a seperate directory, which are loaded and cached | ||
* on application boot. Later you can access the values using the `dot` syntax. | ||
* | ||
* ## Access values | ||
* | ||
* 1. **Given the config file is stored as `config/app.js` with following content** | ||
* | ||
* ```js | ||
* module.exports = { | ||
* appKey: '' | ||
* } | ||
* ``` | ||
* | ||
* 2. **You access the appKey as follows** | ||
* | ||
* ```js | ||
* Config.get('app.appKey') | ||
* ``` | ||
* | ||
* **NOTE:** | ||
* The `get` method doesn't raise runtime exceptions when top level objects are missing. | ||
*/ | ||
export declare class Config implements ConfigContract { | ||
private _config; | ||
constructor(_config?: {}); | ||
private config; | ||
constructor(config?: {}); | ||
/** | ||
* Read value from the pre-loaded config. Make use of the `dot notation` | ||
* syntax to read nested values. | ||
* | ||
* The `defaultValue` is returned when original value is `undefined`. | ||
* | ||
* @example | ||
* ```js | ||
* Config.get('database.mysql') | ||
* ``` | ||
*/ | ||
get(key: string, defaultValue?: any): any; | ||
/** | ||
* Fetch and merge an object to the existing config. This method is useful | ||
* when you are fetching an object from the config and want to merge | ||
* it with some default values. | ||
* | ||
* An optional customizer can be passed to customize the merge operation. | ||
* The function is directly passed to [lodash.mergeWith](https://lodash.com/docs/4.17.10#mergeWith) | ||
* method. | ||
* | ||
* @example | ||
* ```js | ||
* // Config inside the file will be merged with the given object | ||
* | ||
* Config.merge('database.mysql', { | ||
* host: '127.0.0.1', | ||
* port: 3306 | ||
* }) | ||
* ``` | ||
*/ | ||
merge(key: string, defaultValues: object, customizer?: Function): any; | ||
/** | ||
* Defaults allows providers to define the default config for a | ||
* module, which is merged with the user config | ||
*/ | ||
defaults(key: string, value: any): void; | ||
/** | ||
* Update in memory value of the pre-loaded config | ||
* | ||
* @example | ||
* ```js | ||
* Config.set('database.host', '127.0.0.1') | ||
* ``` | ||
*/ | ||
set(key: string, value: any): void; | ||
} |
"use strict"; | ||
/* | ||
* @adonisjs/config | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const lodash_1 = require("lodash"); | ||
/// <reference path="../adonis-typings/config.ts" /> | ||
const lodash_get_1 = __importDefault(require("lodash.get")); | ||
const lodash_set_1 = __importDefault(require("lodash.set")); | ||
const lodash_mergewith_1 = __importDefault(require("lodash.mergewith")); | ||
/** | ||
* Config module eases the process of using configuration inside your AdonisJs | ||
* applications. | ||
* | ||
* The config files are stored inside a seperate directory, which are loaded and cached | ||
* on application boot. Later you can access the values using the `dot` syntax. | ||
* | ||
* ## Access values | ||
* | ||
* 1. **Given the config file is stored as `config/app.js` with following content** | ||
* | ||
* ```js | ||
* module.exports = { | ||
* appKey: '' | ||
* } | ||
* ``` | ||
* | ||
* 2. **You access the appKey as follows** | ||
* | ||
* ```js | ||
* Config.get('app.appKey') | ||
* ``` | ||
* | ||
* **NOTE:** | ||
* The `get` method doesn't raise runtime exceptions when top level objects are missing. | ||
*/ | ||
class Config { | ||
constructor(_config = {}) { | ||
this._config = _config; | ||
constructor(config = {}) { | ||
this.config = config; | ||
} | ||
/** | ||
* Read value from the pre-loaded config. Make use of the `dot notation` | ||
* syntax to read nested values. | ||
* | ||
* The `defaultValue` is returned when original value is `undefined`. | ||
* | ||
* @example | ||
* ```js | ||
* Config.get('database.mysql') | ||
* ``` | ||
*/ | ||
get(key, defaultValue) { | ||
return lodash_1.get(this._config, key, defaultValue); | ||
return lodash_get_1.default(this.config, key, defaultValue); | ||
} | ||
/** | ||
* Fetch and merge an object to the existing config. This method is useful | ||
* when you are fetching an object from the config and want to merge | ||
* it with some default values. | ||
* | ||
* An optional customizer can be passed to customize the merge operation. | ||
* The function is directly passed to [lodash.mergeWith](https://lodash.com/docs/4.17.10#mergeWith) | ||
* method. | ||
* | ||
* @example | ||
* ```js | ||
* // Config inside the file will be merged with the given object | ||
* | ||
* Config.merge('database.mysql', { | ||
* host: '127.0.0.1', | ||
* port: 3306 | ||
* }) | ||
* ``` | ||
*/ | ||
merge(key, defaultValues, customizer) { | ||
return lodash_1.mergeWith(defaultValues, this.get(key), customizer); | ||
return lodash_mergewith_1.default(defaultValues, this.get(key), customizer); | ||
} | ||
/** | ||
* Defaults allows providers to define the default config for a | ||
* module, which is merged with the user config | ||
*/ | ||
defaults(key, value) { | ||
const existingValue = this.get(key); | ||
if (existingValue) { | ||
lodash_1.mergeWith(value, existingValue); | ||
lodash_mergewith_1.default(value, existingValue); | ||
} | ||
this.set(key, value); | ||
} | ||
/** | ||
* Update in memory value of the pre-loaded config | ||
* | ||
* @example | ||
* ```js | ||
* Config.set('database.host', '127.0.0.1') | ||
* ``` | ||
*/ | ||
set(key, value) { | ||
lodash_1.set(this._config, key, value); | ||
lodash_set_1.default(this.config, key, value); | ||
} | ||
} | ||
exports.Config = Config; |
"use strict"; | ||
/* | ||
* @adonisjs/config | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Config_1 = require("./src/Config"); | ||
exports.Config = Config_1.Config; |
{ | ||
"name": "@adonisjs/config", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Config management for Adonis framework", | ||
"main": "build/providers/ConfigProvider.js", | ||
"files": [ | ||
@@ -17,3 +18,3 @@ "build/adonis-typings", | ||
"version": "npm run build", | ||
"lint": "tslint --project tsconfig.json", | ||
"lint": "eslint . --ext=.ts", | ||
"clean": "del build", | ||
@@ -32,6 +33,6 @@ "compile": "npm run lint && npm run clean && tsc", | ||
"devDependencies": { | ||
"@adonisjs/fold": "^6.1.7", | ||
"@adonisjs/mrm-preset": "^2.1.0", | ||
"@types/lodash": "^4.14.138", | ||
"@types/node": "^12.7.4", | ||
"@adonisjs/fold": "^6.2.3", | ||
"@adonisjs/mrm-preset": "^2.2.3", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^12.12.21", | ||
"commitizen": "^4.0.3", | ||
@@ -41,13 +42,13 @@ "cz-conventional-changelog": "^3.0.2", | ||
"doctoc": "^1.4.0", | ||
"husky": "^3.0.5", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-adonis": "^1.0.4", | ||
"husky": "^3.1.0", | ||
"japa": "^3.0.1", | ||
"mrm": "^1.2.2", | ||
"np": "^5.0.3", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.19.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typedoc": "^0.15.0", | ||
"mrm": "^2.0.2", | ||
"np": "^5.2.1", | ||
"ts-node": "^8.5.4", | ||
"typedoc": "^0.15.5", | ||
"typedoc-plugin-external-module-name": "^2.1.0", | ||
"typedoc-plugin-markdown": "^2.1.11", | ||
"typescript": "^3.6.2" | ||
"typedoc-plugin-markdown": "^2.2.14", | ||
"typescript": "^3.7.4" | ||
}, | ||
@@ -78,4 +79,6 @@ "nyc": { | ||
"dependencies": { | ||
"@poppinss/utils": "^2.0.0", | ||
"lodash": "^4.17.15" | ||
"@poppinss/utils": "^2.1.1", | ||
"lodash.get": "^4.4.2", | ||
"lodash.mergewith": "^4.6.2", | ||
"lodash.set": "^4.3.2" | ||
}, | ||
@@ -82,0 +85,0 @@ "directories": { |
@@ -29,3 +29,2 @@ <div align="center"> | ||
- [API](#api) | ||
- [Maintainers](#maintainers) | ||
@@ -74,3 +73,3 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
export const providers = [ | ||
'@adonisjs/config/build/providers/ConfigProvider', | ||
'@adonisjs/config', | ||
] | ||
@@ -173,11 +172,9 @@ ``` | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[typescript-url]: "typescript" | ||
[npm-image]: https://img.shields.io/npm/v/@adonisjs/config.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/@adonisjs/config "npm" | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
[license-url]: LICENSE.md | ||
[license-image]: https://img.shields.io/aur/license/pac.svg?style=for-the-badge | ||
## Maintainers | ||
[Harminder virk](https://github.com/thetutlage) | ||
[license-image]: https://img.shields.io/npm/l/@adonisjs/config?color=blueviolet&style=for-the-badge | ||
[license-url]: LICENSE.md "license" |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance 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
16481
258
4
178
1
+ Addedlodash.get@^4.4.2
+ Addedlodash.mergewith@^4.6.2
+ Addedlodash.set@^4.3.2
+ Addedlodash.get@4.4.2(transitive)
+ Addedlodash.mergewith@4.6.2(transitive)
+ Addedlodash.set@4.3.2(transitive)
- Removedlodash@^4.17.15
- Removedlodash@4.17.21(transitive)
Updated@poppinss/utils@^2.1.1