Coder Social home page Coder Social logo

activerules-middleware's Introduction

activerules-middleware

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

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.

Checkout ActiveRules Phalcon and Nugget

Sponsored By:

UltriNet

activerules-middleware's People

Contributors

bwinkers avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.