Skip to content

Releases: malijs/mali

0.2.2

11 Mar 18:22
Compare
Choose a tag to compare

Changes

  • Fix passing of load options

All changes: 0.2.1...0.2.2

0.2.1

06 Mar 16:57
Compare
Choose a tag to compare

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

20 Feb 02:25
Compare
Choose a tag to compare

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 account
  • use signature is changed to use(service, name, ...fns), where service is the service name and name is the rpc name
    • if service and name are given applies fns for that call under that service

      app.use('Greeter', 'sayHello', handler)
    • if service name is provided and matches one of the services defined in proto, but no name is provided applies the fns as middleware as service level middleware for all handlers in that service

      app.use('Greeter', mwForGreeter)
    • if service is provided and no name is provided, and service does not match any of the service names in the proto, assumes service is actually rpc call name. Uses 0th 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 services

      app.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 but 0th key does not match any of the services in proto, assumes 0th service. Useful for protos with only one service.

      app.use({
        sayGoodbye: handler1, 
        sayHello: [ mw3, handler2 ] 
      })