4.0.0 • Published 7 years ago

activerules-middleware v4.0.0

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

activerules-middleware

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

Promised-based middleware to load configs.

Overview

Loopback / Express middleware to support dynamic logic based on hostname or domain. The configs for the host and domain are merged and available in the request past that point. This is useful when supporting skinned versions versions of apps for multiple domains.

It was developed for use with Loopback 3 but should work with any Express based app.

Install

    npm install --save activerules-middleware

Add it early in the Loopback middleware.json initial phase:

    "initial": {
        "./middleware/performance-tracker": {},
        "activerules-middleware": {
            "params": "../../../common/ar"
        },
        "compression": {},

The params needs to be a a string representing the location of the ActiveRules configs.

The params directory must include two subdirectory: host and site.

Testing

    npm test

Public CI Testing Results:

CodeShip

https://app.codeship.com/projects/240160

Travis CI

https://travis-ci.org/bwinkers/activerules-middleware

Build Status

Coveralls - test coverage

Coverage Status

Usage

Examples of the host and site configs can be found in the test directory.

Hostname Config

  • The site hostname must have a .json file for the root domain in the host directory.
  • That file must define a site property, and th value must correspond to a .json file in the site directory.
  • Any additional properties will be merged with values in the site config.
  • This allows setting prod defaults in the site config and overriding them on a hostname basis.

Site Config

The site config file is a free form JSON object. It's properties will be merged with the host file using Lodash.

Request object changes

If a valid site is found the Express request object will have a site property added to it.

Check back soon...

4.0.0

7 years ago

3.0.19

7 years ago

3.0.18

7 years ago

3.0.14

7 years ago

3.0.13

7 years ago

3.0.12

7 years ago

3.0.11

7 years ago

3.0.10

7 years ago

3.0.8

7 years ago

3.0.7

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago