Skip to content

Commit

Permalink
Merge pull request #17 from aliyun/fc2-master
Browse files Browse the repository at this point in the history
FC2 first version 2.0.0
  • Loading branch information
rockuw committed Dec 14, 2017
2 parents 91c0185 + 42156ab commit e1249ed
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 89 deletions.
29 changes: 26 additions & 3 deletions README.md
Expand Up @@ -14,12 +14,35 @@ fc-nodejs-sdk

Documents: http://doxmate.cool/aliyun/fc-nodejs-sdk/api.html

## Install
Notice
-------------------
We suggest using fc2,The main difference between fc and fc2 is:

The response returned by the user is the following dict, for invoke function, data is bytes, for other apis, data is dict.

```js
{
'headers': headers,
'data': data,
}

```

Install the official fc2 release version:

```bash
npm install @alicloud/fc2 --save
```

## Install oldVersion

fc version is in 1.x branch, you can install fc use 'npm' like this

```bash
npm install @alicloud/fc --save
```


## License

[MIT](LICENSE)
Expand All @@ -31,7 +54,7 @@ npm install @alicloud/fc --save
```js
'use strict';

var FCClient = require('@alicloud/fc');
var FCClient = require('@alicloud/fc2');

var client = new FCClient('<account id>', {
accessKeyID: '<access key id>',
Expand Down Expand Up @@ -69,7 +92,7 @@ client.createService(serviceName).then(function(resp) {
```js
'use strict';

const FCClient = require('@alicloud/fc');
const FCClient = require('@alicloud/fc2');

var client = new FCClient('<account id>', {
accessKeyID: '<access key id>',
Expand Down
41 changes: 22 additions & 19 deletions es5/client.js
Expand Up @@ -104,7 +104,7 @@ var Client = function () {
this.endpoint = `${protocol}://${accountid}.${region}${internal}.fc.aliyuncs.com`;
this.host = `${accountid}.${region}${internal}.fc.aliyuncs.com`;
this.version = '2016-08-15';
this.timeout = Number.isFinite(config.timeout) ? config.timeout : 10000; // default is 10s
this.timeout = Number.isFinite(config.timeout) ? config.timeout : 60000; // default is 60s
}

_createClass(Client, [{
Expand All @@ -127,7 +127,7 @@ var Client = function () {
}, {
key: 'request',
value: function () {
var _ref = _asyncToGenerator(_regenerator2.default.mark(function _callee(method, path, query, body) {
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(method, path, query, body) {
var headers = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
var url, postBody, buff, digest, md5, stringToSign, signature, response, responseBody, contentType, code, requestid, err;
return _regenerator2.default.wrap(function _callee$(_context) {
Expand Down Expand Up @@ -231,7 +231,10 @@ var Client = function () {
throw err;

case 34:
return _context.abrupt('return', responseBody);
return _context.abrupt('return', {
'headers': response.headers,
'data': responseBody
});

case 35:
case 'end':
Expand Down Expand Up @@ -318,7 +321,7 @@ var Client = function () {
*
* @param {String} serviceName 服务名
* @param {Object} options 选项,optional
* @return {Promise} 返回 ServiceResponse
* @return {Promise} 返回 Object(包含headers和data属性[ServiceResponse])
*/

}, {
Expand All @@ -342,7 +345,7 @@ var Client = function () {
* - nextToken
*
* @param {Object} options 选项,optional
* @return {Promise} 返回 Service 列表
* @return {Promise} 返回 Object(包含headers和data属性[Service 列表])
*/

}, {
Expand All @@ -358,7 +361,7 @@ var Client = function () {
* 获取service信息
*
* @param {String} serviceName
* @return {Promise} 返回 Service 信息
* @return {Promise} 返回 Object(包含headers和data属性[Service 信息])
*/

}, {
Expand All @@ -377,7 +380,7 @@ var Client = function () {
*
* @param {String} serviceName 服务名
* @param {Object} options 选项,optional
* @return {Promise} 返回 Service 信息
* @return {Promise} 返回 Object(包含headers和data属性[Service 信息])
*/

}, {
Expand All @@ -393,7 +396,7 @@ var Client = function () {
* 删除Service
*
* @param {String} serviceName
* @return {Promise}
* @return {Promise} 返回 Object(包含headers和data属性)
*/

}, {
Expand Down Expand Up @@ -439,7 +442,7 @@ var Client = function () {
*
* @param {String} serviceName
* @param {Object} options 选项,optional
* @return {Promise} 返回Function列表
* @return {Promise} 返回 Object(包含headers和data属性[Function列表])
*/

}, {
Expand All @@ -456,7 +459,7 @@ var Client = function () {
*
* @param {String} serviceName
* @param {String} functionName
* @return {Promise} 返回 Function 信息
* @return {Promise} 返回 Object(包含headers和data属性[Function信息])
*/

}, {
Expand All @@ -470,7 +473,7 @@ var Client = function () {
*
* @param {String} serviceName
* @param {String} functionName
* @return {Promise} 返回 Function Code 信息
* @return {Promise} 返回 Object(包含headers和data属性[Function信息])
*/

}, {
Expand All @@ -485,7 +488,7 @@ var Client = function () {
* @param {String} serviceName
* @param {String} functionName
* @param {Object} options Function配置,见createFunction
* @return {Promise} 返回 Function 信息
* @return {Promise} 返回 Object(包含headers和data属性[Function信息])
*/

}, {
Expand All @@ -500,7 +503,7 @@ var Client = function () {
*
* @param {String} serviceName
* @param {String} functionName
* @return {Promise}
* @return {Promise} 返回 Object(包含headers和data属性)
*/

}, {
Expand All @@ -519,7 +522,7 @@ var Client = function () {
* @param {String} serviceName
* @param {String} functionName
* @param {Object} event event信息
* @return {Promise} 返回Function的执行结果
* @return {Promise} 返回 Object(包含headers和data属性[返回Function的执行结果])
*/

}, {
Expand Down Expand Up @@ -547,7 +550,7 @@ var Client = function () {
* @param {String} serviceName 服务名
* @param {String} functionName 服务名
* @param {Object} options Trigger配置
* @return {Promise} 返回 Trigger 信息
* @return {Promise} 返回 Object(包含headers和data属性[Trigger信息])
*/

}, {
Expand All @@ -569,7 +572,7 @@ var Client = function () {
* @param {String} serviceName
* @param {String} functionName
* @param {Object} options 选项,optional
* @return {Promise} 返回Trigger列表
* @return {Promise} 返回 Object(包含headers和data属性[Trigger列表])
*/

}, {
Expand All @@ -588,7 +591,7 @@ var Client = function () {
* @param {String} serviceName
* @param {String} functionName
* @param {String} triggerName
* @return {Promise} 返回 Trigger 信息
* @return {Promise} 返回 Object(包含headers和data属性[Trigger信息])
*/

}, {
Expand All @@ -605,7 +608,7 @@ var Client = function () {
* @param {String} functionName
* @param {String} triggerName
* @param {Object} options Trigger配置,见createTrigger
* @return {Promise} 返回 Trigger 信息
* @return {Promise} 返回 Object(包含headers和data属性[Trigger信息])
*/

}, {
Expand All @@ -621,7 +624,7 @@ var Client = function () {
* @param {String} serviceName
* @param {String} functionName
* @param {String} triggerName
* @return {Promise}
* @return {Promise} 返回 Object(包含headers和data属性)
*/

}, {
Expand Down

0 comments on commit e1249ed

Please sign in to comment.