Get configuration from model with krakenJS

49 views
Skip to first unread message

Paulo Antonio McNally Zambrana

unread,
Jan 30, 2015, 12:43:43 PM1/30/15
to nod...@googlegroups.com
How to get req.app.kraken.get('api_url'); from a model with krakenJS?

req its from a route, but i a need set api_url into a model.

Thanks

Aria Stewart

unread,
Jan 30, 2015, 1:44:43 PM1/30/15
to nod...@googlegroups.com

> On Jan 30, 2015, at 12:43 PM, Paulo Antonio McNally Zambrana <paulom...@gmail.com> wrote:
>
> How to get req.app.kraken.get('api_url'); from a model with krakenJS?
>
> req its from a route, but i a need set api_url into a model.

Good question! Kraken's configurations are pretty isolated -- usually, having to do this is a smell that things aren't as separate as they should be (presentation layer things mixed with business logic), but sometimes that's how it works out.

You can attach an onconfig handler to kraken in index.js, which, when called, can inject the configuration into the model. Just be aware that it's asynchronous, so don't rely on it until onconfig has fired, or the app emits the start event.

Aria

Reply all
Reply to author
Forward
0 new messages