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

ali-api-gateway

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ali-api-gateway - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

release.md

2

package.json
{
"name": "ali-api-gateway",
"version": "0.0.7",
"version": "0.0.8",
"description": "proxy ali api gate way",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict';
const co = require('co');
const parseParams = require('./parse-params.js');
const parseFile = require('./parseFiles.js');
const parseFile = require('./parse-files.js');
const log = require('./log.js');

@@ -46,3 +46,3 @@

while (index--) {
prev = middlewares[index].bind(ctx, prev);
prev = middlewares[index].bind(null, ctx, prev);
}

@@ -49,0 +49,0 @@ yield prev();

@@ -7,4 +7,6 @@ 'use strict';

const headers = options.headers || {};
const files = options.files || {};
const event = {
body: body,
files: files,
headers: headers,

@@ -11,0 +13,0 @@ httpMethod: 'POST',

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

module.exports = function *(next) {
module.exports = function *(ctx, next) {
let success = true;

@@ -46,4 +46,4 @@ const start = new Date();

const duration = end - start;
const req = this.req;
const context = this.context;
const req = ctx.req;
const context = ctx.context;
const ref = `https://serverless.ele.me/${req.path}`;

@@ -50,0 +50,0 @@ const basicInfo = {

@@ -10,5 +10,4 @@ 'use strict';

module.exports = function *(next) {
const self = this;
const event = JSON.parse(this.event.toString());
module.exports = function *(ctx, next) {
const event = JSON.parse(ctx.event.toString());
if (event.body && event.isBase64Encoded) {

@@ -19,6 +18,6 @@ event.body = JSON.parse(new Buffer(event.body, 'base64').toString());

if (!event.body) event.body = {};
this.newError = newError;
this.req = event;
this.body = {};
this.res = {
ctx.newError = newError;
ctx.req = event;
ctx.body = {};
ctx.res = {
headers: {},

@@ -28,6 +27,6 @@ statusCode: 200

this.result = yield co(function *() {
ctx.result = yield co(function *() {
yield next();
self.res.body = self.body;
return self.res;
ctx.res.body = ctx.body;
return ctx.res;
}).catch(err => {

@@ -34,0 +33,0 @@ return wrapError(err);

module.exports = function *(next) {
yield next();
// Connection:keep-alive
// Content-Length:4
// Content-Type:text/plain; charset=utf-8
// Date:Tue, 18 Jul 2017 06:19:55 GMT
};

@@ -8,17 +8,17 @@ 'use strict';

const api = new Api({parseParams: false});
api.use(function *(next) {
this.result = [];
this.result.push(1);
api.use(function *(ctx, next) {
ctx.result = [];
ctx.result.push(1);
yield next();
this.result.push(5);
ctx.result.push(5);
});
api.use(function *(next) {
this.result.push(2);
api.use(function *(ctx, next) {
ctx.result.push(2);
yield next();
this.result.push(4);
ctx.result.push(4);
});
api.use(function *() {
this.result.push(3);
api.use(function *(ctx) {
ctx.result.push(3);
});

@@ -34,6 +34,6 @@

const api = new Api({parseParams: false});
api.use(function *() {
this.result = {
event: this.event.toString(),
context: this.context
api.use(function *(ctx) {
ctx.result = {
event: ctx.event.toString(),
context: ctx.context
};

@@ -53,3 +53,3 @@ });

const api = new Api({parseParams: false});
api.use(function *() {
api.use(() => {
throw new Error('test');

@@ -56,0 +56,0 @@ });

@@ -10,9 +10,9 @@ 'use strict';

const api = new Api();
api.use(function *() {
t.deepEqual(this.req.body, {haha: 'haha'});
t.deepEqual(this.req.queryParameters, {test: 'test'});
this.body = 'test';
api.use(function *(ctx) {
t.deepEqual(ctx.req.body, {haha: 'haha'});
t.deepEqual(ctx.req.queryParameters, {test: 'test'});
ctx.body = 'test';
});
http(api.wrap(), {params: {test: 'test'}, body: {haha: 'haha'}}, function(err, res) {
t.deepEqual(res, { headers: {}, encoding: 'utf8', file: null, statusCode: 200, body: 'test' });
t.deepEqual(res, { headers: {}, encoding: 'utf8', statusCode: 200, body: 'test' });
t.end();

@@ -24,4 +24,4 @@ });

const api = new Api();
api.use(function *() {
throw this.newError(400, 'error params');
api.use(function *(ctx) {
throw ctx.newError(400, 'error params');
});

@@ -28,0 +28,0 @@ http(api.wrap(), {params: {test: 'test'}, body: {haha: 'haha'}}, function(err, res) {

@@ -20,6 +20,6 @@ 'use strict';

const api = new Api();
api.use(function *() {
this.body = 'test';
t.true(this.req.test === 'test');
t.true(this.context.haha === 'haha');
api.use(function *(ctx) {
ctx.body = 'test';
t.true(ctx.req.test === 'test');
t.true(ctx.context.haha === 'haha');
});

@@ -35,4 +35,4 @@ api.wrap()(new Buffer(JSON.stringify(Object.assign(basicEvent, {test: 'test'}))), Object.assign(basicContext, {haha: 'haha'}), function(err, res) {

const api = new Api();
api.use(function *() {
throw this.newError(400, 'error params');
api.use(function *(ctx) {
throw ctx.newError(400, 'error params');
});

@@ -39,0 +39,0 @@ api.wrap()(new Buffer(JSON.stringify(Object.assign(basicEvent, {test: 'test'}))), Object.assign(basicContext, {haha: 'haha'}), function(err, res) {

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