项目作者: Platekun

项目描述 :
A set of functions to help you build Bizagi custom connectors easier.
高级语言: JavaScript
项目地址: git://github.com/Platekun/bzg.git
创建时间: 2017-07-25T18:01:59Z
项目社区:https://github.com/Platekun/bzg

开源协议:

下载


bzg

A set of functions to help you build Bizagi custom connectors easier.

Installation

npm install --save bzg

API

createResponse(res, err, statusCode): Creates a Bizagi formatted response. This is a special format used by Bizagi studio.

  • res: Object: HTTP request object.
  • err: Object: Request error object.
  • statusCode: String: How’s the statusCode property called in the response object passed in. ex: “status”, “status-code”, etc.

createError(): Creates a human readable error. This is the error that users will see once the exception occurs doing the action.

  • errorType: String: An object containing the type of error it will be passed on to Bizagi. The following errors are supported.
    • GLB.UNKNOW_ACTION
    • GLB.RESPONSE_ERROR
    • REQUIRED_PARAM
  • params: Object: The parameters needed to build that type of error.
    • { action: String }
    • { code: Number, errorMessage: String }
    • { paramName: String }

findMissingParams(params): Generic function that checks the user input the same way Bizagi studio expects. It returns a string error if there’s a missing param.

  • params: Object: Bizagi user input

Use

  1. import bzg from 'bzg';
  2. import imgur from 'imgur';
  3. import consumer from './some-path/consumer';
  4. export function _action(handlers, services, authdata, input) {
  5. // handlers.findMissingParams({/**/});
  6. // services.imgur.setClientId('aCs53GSs4tga0ikp');
  7. // services.consumer.init(imgur);
  8. // ...
  9. // handlers.createResponse({ statusCode: 200 });
  10. // ...
  11. // Remenber to return a Promise.
  12. }
  13. export const invoke = bzg( [imgur, consumer], _action);