Skip to content

Conversation

scottinet
Copy link
Contributor

6.0.0 (2019-01-17)

Bug fixes

  • [ #359 ] Fixed call to checkToken after reconnection (xbill82)
  • [ #355 ] React native compatibility (scottinet)
  • [ #349 ] [build] Update webpack build config to fix raw web usage (Njuelle)
  • [ #345 ] Fix 343 unhandled rejection on connect (Aschen)

New features

  • [ #353 ] Add method to use custom controllers in the SDK (Aschen)

Enhancements

  • [ #350 ] Have host param mandatory for protocols (Aschen)

Others

  • [ #348 ] Put document:create optional args in last position (Aschen)

Aschen and others added 26 commits December 19, 2018 16:54
Fix #343 unhandled rejection on connect retry.
Change parameters order for collection:create to put optional param in last position
Update webpack build config to fix undefined protocol classes in raw web usage :

    change webpack entrypoint to include all classes
    rename library name to avoid Kuzzle.Kuzzle ...
    add BUILT global constant to avoid exception when used in raw web

everything remains unchanged for use with Webpack and NodeJS
The host param is now mandatory for protocols. The new constructor signature include mandatory host param and optional options param.
Adds a `useController` method to the Kuzzle object to use custom defined controllers.  
This allows to call plugin routes from the SDK without using the `query` method.

If I have a plugin with the following action: 
```
    this.controllers = {
      test: {
        sayHello: 'sayHello'
      }
    };

    this.routes = [
      { verb: 'get', url: '/test/sayHello', controller: 'test', action: 'sayHello' }
    ];

  async sayHello (request) {
    const message = request.input.args.message || request.input.body.message;

    return message;
  }
```

Then I can define the following custom controller and use it in the SDK:
```
class TestController extends BaseController {
  constructor (accessor) {
    super('ctoi-le-plugin/test', accessor);
  }

  sayHello (message, options) {
    const request = {
      action: 'sayHello',
      body: {
        message
      }
    };

    return this.query(request, options)
      .then(response => response.result);
  }
}

const kuzzle = new Kuzzle(new WebSocket('localhost'));

kuzzle.useController(new TestController('test'))

console.log(await kuzzle.test.sayHello('Hello moto'))
```
Co-Authored-By: scottinet <[email protected]>
Fixes a call to `checkToken` upon reconnection to Kuzzle. The previous version was surely a copy/paste error based on v5.
@scottinet scottinet closed this Jan 17, 2019
@scottinet scottinet deleted the 6.0.0-proposal branch January 17, 2019 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants