1 | _ = require 'lodash'
|
2 |
|
3 | module.exports = (extensionName, core) ->
|
4 |
|
5 | # prefix the channel with the extensionName
|
6 | limit = (fn) ->
|
7 | safe = (channel, args...) ->
|
8 | fn "#{extensionName}.#{channel}", args...
|
9 | safe.extensionName = extensionName
|
10 | return safe
|
11 |
|
12 | api = {
|
13 | # TODO: limit to extension and create default routing
|
14 | log: _.omit core.log, 'coreEntry'
|
15 | }
|
16 |
|
17 | # all these functions take 'channel' as their first arg,
|
18 | # so apply 'limit' to them to limit the namespace
|
19 | for fn in ['request', 'delegate', 'respond', 'respondOnce', 'send', 'listen']
|
20 | api[fn] = limit core[fn]
|
21 |
|
22 | return Object.freeze api
|