read-appsettings-json
TypeScript icon, indicating that this package has built-in type declarations

1.0.98 • Public • Published

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.

read-appsettings-json

npm version Build Status npm GitHub issues npm

Getting Started

  1. install read-appsettings-json through npm package using the following command:

     `npm install read-appsettings-json --save`
    
  2. You need to create a appsettings.json file in the root of your project. Let's create the following appsettings.json

{
    "apiendpoint": "http://localhost:3035",
    "second":2,
    "booleanflag":true
}

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.

  1. use it as following
// Service Class    
import { AppConfiguration } from "read-appsettings-json";
 
 console.log(AppConfiguration.Setting().apiendpoint);

ANOTHER Example

{
    "day": 1,
    "year":2017,
    "month":12
}

TYPESCRIPT WOULD BE

// Service Class    
import { AppConfiguration } from "read-appsettings-json";
 
console.log(AppConfiguration.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"
  ]
}

Please take a look to the demo

Package Sidebar

Install

npm i read-appsettings-json

Weekly Downloads

886

Version

1.0.98

License

MIT

Unpacked Size

6.36 kB

Total Files

7

Last publish

Collaborators

  • codechavez