New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aliyun-api-gateway

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aliyun-api-gateway - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

es5/base.js

15

index.js
'use strict';
exports.Client = require('./lib/client');
function supportAsyncFunctions() {
try {
new Function('(async function () {})()');
return true;
} catch (ex) {
return false;
}
}
exports.SimpleClient = require('./lib/simple-client');
const asyncSupported = supportAsyncFunctions();
exports.Client = asyncSupported ? require('./lib/client') : require('./es5/client');
exports.SimpleClient = asyncSupported ? require('./lib/simple-client') : require('./es5/simple-client');
//表单类型Content-Type

@@ -8,0 +19,0 @@ exports.CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded; charset=UTF-8';

@@ -25,3 +25,3 @@ 'use strict';

* get(url, opts = {}) {
get(url, opts = {}) {
var parsed = parse(url, true);

@@ -41,6 +41,6 @@ var maybeQuery = opts.query || opts.data;

return yield* this.request('GET', parsed, opts);
return this.request('GET', parsed, opts);
}
* post(url, opts = {}) {
post(url, opts = {}) {
var parsed = parse(url, true);

@@ -76,7 +76,41 @@ var query = opts.query;

return yield* this.request('POST', url, opts, originData);
return this.request('POST', url, opts, originData);
}
* delete(url, opts) {
put(url, opts = {}) {
var parsed = parse(url, true);
var query = opts.query;
if (query) {
// append data into querystring
Object.assign(parsed.query, query);
parsed.path = parsed.pathname + '?' + querystring.stringify(parsed.query);
opts.query = null;
}
// lowerify the header key
opts.headers = loweredKeys(opts.headers);
opts.signHeaders = loweredKeys(opts.signHeaders);
var headers = opts.headers;
var type = headers['content-type'] || headers['Content-Type'];
if (!type) {
headers['content-type'] = 'application/json';
type = headers['content-type'];
}
var originData = opts.data;
if (type.startsWith('application/x-www-form-urlencoded')) {
opts.data = querystring.stringify(opts.data);
} else if (type.startsWith('application/json')) {
opts.data = JSON.stringify(opts.data);
} else if (!Buffer.isBuffer(opts.data) && typeof opts.data !== 'string') {
// 非buffer和字符串时,以JSON.stringify()序列化
opts.data = JSON.stringify(opts.data);
}
return this.request('PUT', url, opts, originData);
}
delete(url, opts) {
var parsed = parse(url, true);
var maybeQuery = opts.query || opts.data;

@@ -95,3 +129,3 @@ if (maybeQuery) {

return yield* this.request('DELETE', parsed, opts);
return this.request('DELETE', parsed, opts);
}

@@ -98,0 +132,0 @@ }

20

lib/client.js

@@ -46,3 +46,3 @@ 'use strict';

var contentType = headers['content-type'];
var contentType = headers['content-type'] || '';
if (contentType) {

@@ -64,3 +64,3 @@ list.push(contentType);

if (method === 'POST' && contentType.startsWith(form)) {
if (contentType.startsWith(form)) {
list.push(this.buildUrl(url, data));

@@ -139,3 +139,3 @@ } else {

* request(method, url, opts, originData) {
async request(method, url, opts, originData) {
var signHeaders = opts.signHeaders;

@@ -145,3 +145,3 @@ // 小写化,合并之后的headers

var requestContentType = headers['content-type'];
var requestContentType = headers['content-type'] || '';
if (method === 'POST' && !requestContentType.startsWith(form)) {

@@ -160,3 +160,8 @@ headers['content-md5'] = this.md5(opts.data);

var response = yield httpx.request(parsedUrl, {
if (debug.enabled) {
debug('post body:');
debug('%s', opts.data);
}
var response = await httpx.request(parsedUrl, {
method: method,

@@ -169,3 +174,4 @@ headers: headers,

return opts;
}
},
timeout: opts.timeout
});

@@ -190,3 +196,3 @@

var result = yield httpx.read(response, 'utf8');
var result = await httpx.read(response, 'utf8');
var contentType = response.headers['content-type'] || '';

@@ -193,0 +199,0 @@ if (contentType.startsWith('application/json')) {

@@ -18,3 +18,3 @@ 'use strict';

* request(method, url, opts) {
async request(method, url, opts) {
var options = {

@@ -31,6 +31,7 @@ method: method,

return opts;
}
},
timeout: opts.timeout
};
var response = yield httpx.request(url, options);
var response = await httpx.request(url, options);

@@ -46,3 +47,3 @@ var headers = response.headers;

var result = yield httpx.read(response, 'utf8');
var result = await httpx.read(response, 'utf8');
var contentType = response.headers['content-type'] || '';

@@ -49,0 +50,0 @@ if (contentType.includes('application/json')) {

{
"name": "aliyun-api-gateway",
"version": "1.0.4",
"version": "1.1.0",
"description": "Aliyun API Gateway Node.js SDK",

@@ -10,3 +10,4 @@ "main": "index.js",

"scripts": {
"test": "make test"
"test": "make test",
"prepublishOnly": "babel lib/ -d es5/"
},

@@ -16,18 +17,24 @@ "author": "Jackson Tian",

"dependencies": {
"babel-runtime": "^6.23.0",
"debug": "^2.6.0",
"httpx": "^2.0.0",
"httpx": "^2.1.1",
"uuid": "^3.0.0"
},
"devDependencies": {
"co-mocha": "^1.1.3",
"babel-cli": "^6.24.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.4.0",
"babel-register": "^6.24.1",
"coveralls": "^2.13.1",
"doxmate": "^0.3.1",
"eslint": "^3.11.1",
"expect.js": "^0.3.1",
"istanbul": "^0.4.5",
"mocha": "^3.2.0"
"mocha": "^3.2.0",
"nyc": "^11.0.2"
},
"files": [
"lib",
"es5",
"index.js"
]
}

@@ -6,2 +6,8 @@ Aliyun API Gateway SDK for Node.js

## Status
[![Build Status](https://travis-ci.org/aliyun/api-gateway-nodejs-sdk.svg?branch=master)](https://travis-ci.org/aliyun/api-gateway-nodejs-sdk)
[![Coverage Status](https://coveralls.io/repos/github/aliyun/api-gateway-nodejs-sdk/badge.svg?branch=es5)](https://coveralls.io/github/aliyun/api-gateway-nodejs-sdk?branch=es5)
## Installation

@@ -8,0 +14,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc