1.0.0 • Published 8 years ago
remi-expose v1.0.0
remi-expose
A remi extension that adds the expose method to the target
Installation
npm i remi-expose
Usage
Registering the extension
const remi = require('remi')
const remiExpose = require('remi-expose')
const app = {}
const registrator = remi(app)
registrator.hook(remiExpose())
Once the remi-expose extension is registered, the remi plugins can expose values.
app.expose(key, value)
Used within a plugin to expose a property via app.pluginsname where:
key
- the key assigned (server.plugins[name][key]
).value
- the value assigned.
exports.register = function(app, opts, next) {
app.expose('util', () => console.log('something'))
next()
}
server.expose(obj)
Merges a shallow copy of an object into to the existing content of server.plugins[name]
where:
obj
- the object merged into the exposed properties container.
exports.register = function(app, opts, next) {
app.expose({
util() {
console.log('something')
},
})
next()
}
License
MIT © Zoltan Kochan