Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.4 to 1.0.5

es5/compose.js

45

es5/router.js

@@ -14,2 +14,3 @@ 'use strict';

var assert = require('assert');
var compose = require('./compose.js');

@@ -24,30 +25,2 @@ var methods = ['get', 'head', 'post', 'put', 'delete', 'options', 'patch'];

var wrapFunc = function wrapFunc(funcs) {
return _regenerator2.default.mark(function _callee(ctx, next) {
var index, prev, func;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
index = funcs.length;
prev = next;
while (index--) {
func = funcs[index];
assert(typeof func === 'function', `router add route func: ${typeof func} is not function`);
prev = func.bind(null, ctx, prev);
}
_context.next = 5;
return prev();
case 5:
case 'end':
return _context.stop();
}
}
}, _callee, this);
});
};
var Router = function () {

@@ -67,3 +40,3 @@ function Router() {

assert(typeof funcName === 'string', `router add route funcName: ${typeof funcName} is not string`);
var func = wrapFunc(funcs);
var func = compose(funcs);
var k = signature(method.toUpperCase(), funcName);

@@ -101,7 +74,7 @@ _this.map[k] = func;

var self = this;
return _regenerator2.default.mark(function _callee2(ctx, next) {
return _regenerator2.default.mark(function _callee(ctx, next) {
var funcName, method, func;
return _regenerator2.default.wrap(function _callee2$(_context2) {
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context.prev = _context.next) {
case 0:

@@ -113,3 +86,3 @@ funcName = ctx.context.function.name;

if (func) {
_context2.next = 5;
_context.next = 5;
break;

@@ -121,3 +94,3 @@ }

case 5:
_context2.next = 7;
_context.next = 7;
return func(ctx, next);

@@ -127,6 +100,6 @@

case 'end':
return _context2.stop();
return _context.stop();
}
}
}, _callee2, this);
}, _callee, this);
});

@@ -133,0 +106,0 @@ }

2

index.js
const Api = require('./es5/api.js');
const http = require('./es5/http');
const Router = require('./es5/router.js');
const compose = require('./es5/compose.js');
module.exports = {
compose: compose,
Router: Router,

@@ -7,0 +9,0 @@ http: http,

{
"name": "ali-api-gateway",
"version": "1.0.4",
"version": "1.0.5",
"description": "proxy ali api gate way",

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

README
======
[文档](http://ekitchen-doc.faas.elenet.me/#/md/api-gateway)

@@ -18,1 +18,12 @@ # v0.0.7

* 修改 返回 error 格式。
# v1.0.1
* 修了 headers 和 cookies 返回错误。
# v1.0.2 - v1.0.3 (因为发布问题,不要使用)
# v1.0.4
* 添加 router.use() 接口。
* router.post(funcName, ...funcs) 接口更改。
'use strict';
const assert = require('assert');
const compose = require('./compose.js');

@@ -12,15 +13,2 @@ const methods = ['get', 'head', 'post', 'put', 'delete', 'options', 'patch'];

const wrapFunc = function(funcs) {
return function *(ctx, next) {
var index = funcs.length;
var prev = next;
while (index--) {
const func = funcs[index];
assert(typeof func === 'function', `router add route func: ${typeof func} is not function`);
prev = func.bind(null, ctx, prev);
}
yield prev();
};
};
class Router {

@@ -32,3 +20,3 @@ constructor() {

assert(typeof funcName === 'string', `router add route funcName: ${typeof funcName} is not string`);
const func = wrapFunc(funcs);
const func = compose(funcs);
const k = signature(method.toUpperCase(), funcName);

@@ -35,0 +23,0 @@ this.map[k] = func;

Sorry, the diff of this file is not supported yet

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