# stormpath-config

> Stormpath configuration loader.

Latest version **0.0.27** (published 2017-01-16) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install stormpath-config
pnpm add stormpath-config
yarn add stormpath-config
bun add stormpath-config
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.27 |
| Published | 2017-01-16 |
| First published | 2015-09-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stormpath, Inc. |
| Maintainers | rdegges, robertjd, typerandom |
| Keywords | express, stormpath, authentication, security, configuration |

## Links

- npm: https://www.npmjs.com/package/stormpath-config
- Repository: https://github.com/stormpath/stormpath-node-config
- Issues: https://github.com/stormpath/stormpath-node-config/issues
- npm.io page: https://npm.io/package/stormpath-config

## Dependencies (5)

- [flat](https://npm.io/package/flat.md) ^2.0.0
- [async](https://npm.io/package/async.md) ^2.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.0.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.5.4
- [properties-parser](https://npm.io/package/properties-parser.md) ^0.3.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 0.0.27 (latest) — 2017-01-16
- 0.0.26 — 2016-11-01
- 0.0.25 — 2016-09-27
- 0.0.24 — 2016-08-11
- 0.0.23 — 2016-05-09
- 0.0.22 — 2016-03-03
- 0.0.21 — 2016-02-24
- 0.0.20 — 2016-02-19
- 0.0.19 — 2016-02-19
- 0.0.18 — 2016-01-13
- 0.0.17 — 2016-01-13
- 0.0.16 — 2015-12-18
- 0.0.15 — 2015-12-08
- 0.0.14 — 2015-12-08
- 0.0.13 — 2015-11-16
- … 12 more at https://npm.io/package/stormpath-config/versions

## README

# stormpath-node-config

*Stormpath configuration loader.*

[![NPM Version](https://img.shields.io/npm/v/stormpath-config.svg?style=flat)](https://npmjs.org/package/stormpath-config)
[![NPM Downloads](http://img.shields.io/npm/dm/stormpath-config.svg?style=flat)](https://npmjs.org/package/stormpath-config)
[![Build Status](https://img.shields.io/travis/stormpath/stormpath-node-config.svg?style=flat)](https://travis-ci.org/stormpath/stormpath-node-config)
[![Coverage Status](https://coveralls.io/repos/stormpath/stormpath-node-config/badge.svg?branch=master&service=github)](https://coveralls.io/github/stormpath/stormpath-node-config?branch=master)

This library is responsible for loading the Stormpath configuration.  It is an internal module used by stormpath-node-sdk, and express-stormpath, and is
not meant for general consumption.


## Installation

To install this library, just run:

```
$ npm install stormpath-config --save
```


## Usage

First, start by including the library:

```
var stormpathConfig = require('stormpath-config');
```

Once the library is loaded, you'll need to initialize a new `Loader` object using the library like so:

```
var configLoader = new stormpathConfig.Loader([/* strategies */]);
```

Notice how the first argument is commented out. This needs to be an array of one or many strategies. See [strategies](#strategies) for a list of all supported strategies and on how to create your own.

E.g. below demonstrates how the Stormpath configuration can be created and loaded from only the environment.

```
var strategy = stormpathConfig.strategy;

var configLoader = new StormpathConfig.Loader([
    new strategy.LoadEnvConfigStrategy(),
    new strategy.LoadFileConfigStrategy('~/stormpath.yml')
]);
```

Now, once you got your new `Loader` object all you need to do is call the `configLoader.load(callback)` method to load the configuration data.
You can do this like so:

```
configLoader.load(function (err, config) {
  if (err) {
    console.error(err);
  } else {
    console.log("Configuration loaded:", config);
  }
});
```

## Strategies

### Creating your own strategy

A strategy is simply a prototype that implements a method named `process` that takes the parameters `config` and `callback`. All it expects is that the callback is called with the first argument as an error (null if none) and the second containing the modified/processed config. E.g. as shown below:

```
function MyConfigStrategy () {
}

MyConfigStrategy.prototype.process = function (config, callback) {
  // Apply strategy to config and return result in callback
  config.someNewField = "abc"; // Append someNewField to our config
  callback(null, config);
};
```

### Supported

Some default strategies for loading a configuration has been included. These are accessible through the `strategy` export. I.e. `require('stormpath-config').strategy`.

#### LoadEnvConfigStrategy

Loads configuration from the system environment.

#### LoadAPIKeyConfigStrategy

Loads client API key configuration from a .properties file.

#### LoadFileConfigStrategy

Loads a configuration from either a JSON or YAML file.

#### ExtendConfigStrategy

Extend a the configuration with an existing object.

#### EnrichClientConfigStrategy

Enriches the configuration with client config resolved at runtime.

#### EnrichClientFromRemoteConfigStrategy

Enriches the configuration with client config resolved from the Stormpath API.

#### EnrichIntegrationConfigStrategy

Enriches the configuration with integration config resolved at runtime.

#### EnrichIntegrationFromRemoteConfigStrategy

Enriches the configuration with integration config resolved from the Stormpath API.

#### ValidateClientConfigStrategy

Validates the client configuration.

## Resources

Below are some resources you might find useful:

- [express-stormpath Github repository](https://github.com/stormpath/stormpath-express)
- [express-stormpath documentation](http://docs.stormpath.com/nodejs/express/latest/)
- [Stormpath website](https://stormpath.com)

## Todo

* Write unit tests.

## Contributing

You can make your own contributions by forking this repository, making your
changes in a feature branch, and then issuing a pull request back to this
repository on the `master` branch.

Here's how you might do this if you wanted to contribute something:

```console
$ git clone https://github.com/stormpath/stormpath-node-config.git
$ cd stormpath-node-config
$ git checkout -b feature-somthing-something
$ # make changes
$ git commit -m "This was easy!"
$ # submit a pull request
```

We regularly maintain this repository, and are quick to review pull requests
and accept changes!

We <333 contributions!

## Copyright

Copyright &copy;2015 Stormpath, Inc. and contributors.

This project is open-source via the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).

---
_Source: https://npm.io/package/stormpath-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
