Skip to content

Conversation

scottinet
Copy link
Contributor

@scottinet scottinet commented Jan 17, 2019

6.0.0-beta-6 (2019-01-17)

Bug fixes


Aschen and others added 30 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.
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'))
```
@scottinet scottinet self-assigned this Jan 17, 2019
@scottinet scottinet added wip and removed wip labels Jan 17, 2019
@scottinet scottinet merged commit 1615698 into 6-beta Jan 17, 2019
@scottinet scottinet deleted the 6.0.0-beta-6-proposal branch January 17, 2019 16:09
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