Releases: malijs/mali
0.2.2
0.2.1
Changes
- Add service only if there's at least one handler. Proto definition may contain services that are not intended
to be included in the server. - Fix Context.name docs
- Update
standard
dev dependency
All changes: 0.2.0...0.2.1
0.2.0
Adds support for multiple services, addressing #2. Should be backwards compatible.
Key changes:
name
in constructor is now optional. If not provided all services are taken into accountuse
signature is changed touse(service, name, ...fns)
, whereservice
is the service name andname
is the rpc name-
if
service
andname
are given appliesfns
for that call under that serviceapp.use('Greeter', 'sayHello', handler)
-
if
service
name is provided and matches one of the services defined in proto, but noname
is provided applies thefns
as middleware as service level middleware for all handlers in that serviceapp.use('Greeter', mwForGreeter)
-
if
service
is provided and noname
is provided, andservice
does not match any of the service names in the proto, assumesservice
is actually rpc call name. Uses0
th property in internal services object. Useful for protos with only one service.app.use('sayHello', handler)
-
if an
object
is provided, you can set middleware and handlers for all servicesapp.use(mw1) // global for all services app.use('Service1', mw2) // applies to all Service1 handers app.use({ Service1: { sayGoodbye: handler1, // has mw1, mw2 sayHello: [ mw3, handler2 ] // has mw1, mw2, mw3 }, Service2: { saySomething: handler3 // only has mw1 } })
-
if
object
provided but0
th key does not match any of the services in proto, assumes0
th service. Useful for protos with only one service.app.use({ sayGoodbye: handler1, sayHello: [ mw3, handler2 ] })
-