read-appsettings-json | Simple and easy read appsettings.json file
read-appsettings-json is an easy way to read a local app settings file in a json format.
- Follow me @ http://codechavez.com
read-appsettings-json
Getting Started
-
install read-appsettings-json through npm package using the following command:
`npm install read-appsettings-json --save`
-
You need to create a appsettings.json file in the root of your project. Let's create the following appsettings.json
Now, this like is in a default root as ../../../appsettings.json which can be found at \node_modules\read-appsettings-json\dist\index.js
once you install the package. To access to you property just type its name as shown in the examples below.
Important to remember that you can create different settings as need it.
- use it as following
// Service Class;console.logAppConfiguration.Setting.apiendpoint;
ANOTHER Example
TYPESCRIPT WOULD BE
// Service Class;console.logAppConfiguration.Setting.month
Don't forget to add this code on your tsconfig.json, otherwise appsettings.json will be included into the bundle, defeating the purpose of this library, NO GOOD.
{
// Your code
"exclude": [
"**/appsettings.json",
"**/appsettings.Development.json"
]
}