globals-holder

0.1.0 • Public • Published

Overview

Just a helper class that can hold options/configs and components.

Install

npm install globals-holder --save

API

  • constructor([options])
    • accepts options
  • option(key)
    • returns option set
  • option(key, value)
    • sets value
  • options()
    • returns object representing all options
  • options(moreOptions)
    • sets moreOptions in current options
    • returns Globals
  • component(key)
    • returns component
  • component(key, value)
    • sets component
    • returns Globals
  • fnOption(key)
    • returns option, throwing exception if its not a function
  • bOption(key)
    • returns option, throwing exception if its not a boolean
  • oOption(key)
    • returns option, throwing exception if its not an object
  • sOption(key)
    • returns option, throwing exception if its not a string
  • iOption(key, instance)
    • returns option, throwing exception if its not instanceof given instance
  • config(key)
    • alias to option
  • config(key, value)
    • alias to option
    • returns Globals

Options

  • failSilently optional
    • if this option is true, if you call APIs that throw exceptions, they wont be thrown

Usage

myConfigs = {...}
globals = require('globals-holder')(myConfigs)
...
globals.component("service:user", new UserService())
...
module.exports = (globals)->
    dbUrl = globals.sOption("MONGO_URL")
    userService = globals.component("service:user")
    ...

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    0

Package Sidebar

Install

npm i globals-holder

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • lucastschmidt