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

deployd

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deployd - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

61

lib/event.js

@@ -43,5 +43,8 @@ /**

var original = {};
if(req.method === 'PUT' && req.data) {
// update the current version before committing
Object.keys(req.data).forEach(function (key) {
original[key] = data[key];
data[key] = req.data[key];

@@ -52,3 +55,3 @@ })

// exec handler
err = exec(handler, data, me);
err = exec(handler, data, me, original);

@@ -66,27 +69,55 @@ // without err, commit any changes

function exec(src, data, session) {
var fn, state, serr = sanitize(src);
function exec(src, data, session, original) {
var fn
, state = {}
, errors = {}
, serr = sanitize(src)
;
if(serr) return {handler: serr};
// original fallback
original = original || {};
// fail on sanitize err
if(serr) return {message: serr};
function error(key, val) {
errors[key] = val || true;
}
function cancel(msg, status) {
state.status = status || 400;
throw msg;
}
function hide(property) {
delete data[property];
}
function protect(property) {
if(data[property]) data[property] = original[property] || undefined;
}
// wrap with a function
src = 'function() {' + src + '}';
src = 'function(me) {' + src + '}';
try {
fn = eval('('+ src +')');
state = fn.call(data, session);
fn.call(data, session);
} catch(e) {
state = {status: 500, error: e};
state.status = state.status || 500;
if(typeof e == 'string') {
state.message = e;
} else {
state.message = e.message;
}
}
// handle state
if(state === false) {
state = {status: 401};
} else if(state === true) {
state = undefined;
} else if(state && typeof state != 'object' || Array.isArray(state)) {
state = {error: state};
// if there are errors attach them to state
if(Object.keys(errors).length) {
state.errors = errors;
}
return state;
if(Object.keys(state).length) {
return state;
}
}

@@ -93,0 +124,0 @@

@@ -39,2 +39,7 @@ /**

;
// for non files, default to application/json
if(!isJSON && req.url.indexOf('.') === -1) {
isJSON = true;
}

@@ -123,8 +128,4 @@ // only buffer JSON

server.error(function (err, req, res, next) {
if(typeof err == 'object' && !(err instanceof Error)) {
res.statusCode = err.status || 400;
res.send({error: err});
} else {
res.send(err);
}
res.statusCode = err.status || 400;
res.send(err);
});

@@ -131,0 +132,0 @@

{
"author": "Ritchie Martori",
"name": "deployd",
"version": "0.3.3",
"version": "0.3.4",
"repository": {

@@ -6,0 +6,0 @@ "url": "git://github.com/deployd/deployd.git"

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