influentialpublishers/kvasir

View on GitHub
express.js

Summary

Maintainability
A
0 mins
Test Coverage

const Loader            = require('./loader.js')
const DEFAULT_NAMESPACE = 'DO'

module.exports = ({ namespace=DEFAULT_NAMESPACE, path }) => {

  const Domain = Loader(path)

  return (req, res, next) => {

    if (!req[namespace]) req[namespace] = Domain

    return next()

  }

}