@kapitchi/bb-service-seneca

0.1.2 • Public • Published

bb-service-seneca

Seneca related service tools.

Installation

npm install @kapitchi/bb-service-seneca

Usage

TODO

API

Classes

SenecaClient

Seneca client

SenecaFactory

Seneca factory

SenecaServer

SenecaClient

Seneca client

Kind: global class

new SenecaClient(seneca)

Param Type
seneca Seneca

senecaClient.act(serviceName, method, params) ⇒ Promise

Calls seneca.act() with action pattern:

  • bbservice - serviceName
  • bbmethod - method

Args object is merged with bbservice/bbmethod seneca pattern object.

Kind: instance method of SenecaClient

Param Type
serviceName string
method string
params Object

SenecaFactory

Seneca factory

Kind: global class

SenecaFactory.createProxyServices(config, senecaClient) ⇒ Object

TODO

Kind: static method of SenecaFactory
Returns: Object - Proxy services created

Param Type
config Object
senecaClient SenecaClient

SenecaFactory.createProxyService(serviceName, senecaClient, opts) ⇒ Object | Proxy

Creates local-like service proxying to seneca client

If used in environment where Proxy class is not available define opts.methods parameter. This creates plain object with methods defined instead of using Proxy.

Kind: static method of SenecaFactory

Param Type Description
serviceName string
senecaClient SenecaClient
opts Object
[opts.methods] Array Array of methods to proxy (creates plain object instead of using Proxy)

SenecaFactory.createPlugin(obj, opts) ⇒ function

Creates seneca plugin from the service class instance

Exposes each service method with action pattern:

  • bbservice - service name
  • bbmethod - method name

Kind: static method of SenecaFactory
Returns: function - Seneca plugin

Param Type Description
obj Object Service instance
opts Object
opts.methods Array Service methods to expose
[opts.service] string Service name (default: object's constructor name)
[opts.pluginName] string Seneca plugin name (default: service name)
[opts.initMethod] string Register service method as Seneca initialization action http://senecajs.org/docs/tutorials/how-to-write-a-plugin.html#wp-init
[opts.logger] Object Logger { log: fn }

SenecaServer

Kind: global class

new SenecaServer(senecaServerOpts, senecaServerExposedServices)

Param Type Description
senecaServerOpts Object
senecaServerOpts.port number
senecaServerOpts.params Object Seneca params
senecaServerExposedServices Object Services to expose

Example

const server = new SenecaServer({
 port: 8080
}, {
 myService: {
   instance: myServiceImp //service object
   methods: ['firstMethod', 'otherMethod']
 }
})

senecaServer.listen() ⇒ Promise.<void>

Start seneca server

Kind: instance method of SenecaServer

Readme

Keywords

Package Sidebar

Install

npm i @kapitchi/bb-service-seneca

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • matuszeman