Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

claudia-api-builder

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

claudia-api-builder - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

2

package.json
{
"name": "claudia-api-builder",
"version": "1.4.1",
"version": "1.5.0",
"description": "Simplify AWS ApiGateway handling",

@@ -5,0 +5,0 @@ "license": "MIT",

#Claudia API Builder
Claudia API Builder makes it possible to use AWS API Gateway as if it was a lightweight JavaScript web server, so it helps developers get started easily and reduces the learning curve required to launch web APIs in AWS. [Check out this video to see how to create and deploy an API in under 5 minutes](https://vimeo.com/156232471).
Claudia API Builder makes it possible to use AWS API Gateway as if it were a lightweight JavaScript web server, so it helps developers get started easily and reduces the learning curve required to launch web APIs in AWS. [Check out this video to see how to create and deploy an API in under 5 minutes](https://vimeo.com/156232471).

@@ -5,0 +5,0 @@ [![Claudia.js Introduction Video](https://claudiajs.com/assets/claudia-intro-video.png)](https://vimeo.com/156232471)

# Release history
## 1.5.0, 12 July 2016
- support for intercepting and modifying requests
## 1.4.1, 1.4.0, 11 July 2016

@@ -4,0 +8,0 @@

@@ -11,2 +11,3 @@ /*global module, require */

unsupportedEventCallback,
interceptCallback,
prompter = (components && components.prompter) || require('./ask'),

@@ -38,2 +39,40 @@ isApiResponse = function (obj) {

return handlerResult;
},
isThenable = function (param) {
return param && param.then && (typeof param.then === 'function');
},
routeEvent = function (event, context /*, callback*/) {
var handler, result, path;
if (event && event.context && event.context.path && event.context.method) {
path = event.context.path;
if (event.context.method === 'OPTIONS' && customCorsHandler) {
return context.done(null, customCorsHandler(event));
}
handler = routes[path] && routes[path][event.context.method];
if (handler) {
try {
event.lambdaContext = context;
result = handler(event);
if (isThenable(result)) {
return result.then(function (promiseResult) {
context.done(null, packResult(promiseResult, path, event.context.method));
}, function (promiseError) {
context.done(promiseError);
});
} else {
context.done(null, packResult(result, path, event.context.method));
}
} catch (e) {
context.done(e);
}
} else {
context.done('no handler for ' + event.context.method + ' ' + event.context.path);
}
} else {
if (unsupportedEventCallback) {
unsupportedEventCallback.apply(this, arguments);
} else {
context.done('event must contain context.path and context.method');
}
}
};

@@ -94,35 +133,29 @@ ['GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'PATCH'].forEach(function (method) {

};
self.router = function (event, context) {
var handler, result, path;
if (event && event.context && event.context.path && event.context.method) {
path = event.context.path;
if (event.context.method === 'OPTIONS' && customCorsHandler) {
return context.done(null, customCorsHandler(event));
}
handler = routes[path] && routes[path][event.context.method];
if (handler) {
try {
event.lambdaContext = context;
result = handler(event);
if (result && result.then && (typeof result.then === 'function')) {
return result.then(function (promiseResult) {
context.done(null, packResult(promiseResult, path, event.context.method));
}, function (promiseError) {
context.done(promiseError);
});
} else {
context.done(null, packResult(result, path, event.context.method));
}
} catch (e) {
context.done(e);
self.intercept = function (callback) {
interceptCallback = callback;
};
self.router = function (event, context, callback) {
var result,
handleResult = function (r) {
if (!r) {
return context.done(null, null);
}
return routeEvent(r, context, callback);
},
handleError = function (e) {
context.done(e);
};
if (!interceptCallback) {
return routeEvent(event, context, callback);
}
try {
result = interceptCallback(event);
if (isThenable(result)) {
return result.then(handleResult, handleError);
} else {
context.done('no handler for ' + event.context.method + ' ' + event.context.path);
handleResult(result);
}
} else {
if (unsupportedEventCallback) {
unsupportedEventCallback.apply(this, arguments);
} else {
context.done('event must contain context.path and context.method');
}
} catch (e) {
handleError(e);
}

@@ -129,0 +162,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