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

arnie

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arnie - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

40

lib/adapters/serverless.js
'use strict';
const A = require('../');
const ServerlessRequestProvider = require('../providers/serverless-request');
const HttpResponseProvider = require('../providers/http-response');
var _stringify = require('babel-runtime/core-js/json/stringify');
module.exports = options => {
var _stringify2 = _interopRequireDefault(_stringify);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var A = require('../');
var ServerlessRequestProvider = require('../providers/serverless-request');
var HttpResponseProvider = require('../providers/http-response');
module.exports = function (options) {
// TODO: Allow passing additional providers and options
const arnie = A({
var arnie = A({
providers: [HttpResponseProvider(), ServerlessRequestProvider()]
});
return task => {
return (event, context, cb) => {
return function (task) {
return function (event, context, cb) {
// We could hide the payload and only pass it to provider factories
const payload = createPayload(event, context);
return arnie(task, payload).then(result => {
var payload = createPayload(event, context);
return arnie(task, payload).then(function (result) {
cb(null, createResponse(result));
}).catch(error => cb(error, null));
}).catch(function (error) {
return cb(error, null);
});
};

@@ -36,3 +48,3 @@ };

function createResponse(result) {
const response = {
var response = {
statusCode: result.response.statusCode,

@@ -42,7 +54,7 @@ headers: result.response.headers,

};
if (typeof response.body === 'object') {
if ((0, _typeof3.default)(response.body) === 'object') {
try {
response.body = JSON.stringify(response.body);
response.body = (0, _stringify2.default)(response.body);
} catch (error) {
console.warn(`Unable to stringify response body as json: ${ error.message }`);
console.warn('Unable to stringify response body as json: ' + error.message);
response.body = undefined;

@@ -49,0 +61,0 @@ }

'use strict';
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -19,6 +29,6 @@ value: true

return function (result) {
var newPayload = Object.assign({}, payload, result ? result.payload : {});
var newPayload = (0, _assign2.default)({}, payload, result ? result.payload : {});
if (result && funcDetails.outputs) {
var outputs = Object.keys(funcDetails.outputs);
var outputs = (0, _keys2.default)(funcDetails.outputs);

@@ -46,3 +56,3 @@ if (~outputs.indexOf(result.path)) {

payloads.push(payload);
if (payloads.length === itemLength) runNextItem(Object.assign.apply(Object, [{}].concat(payloads)));
if (payloads.length === itemLength) runNextItem(_assign2.default.apply(Object, [{}].concat(payloads)));
}));

@@ -49,0 +59,0 @@ return payloads;

'use strict';
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -14,3 +20,3 @@ value: true

return new Promise(function (resolve) {
return new _promise2.default(function (resolve) {
if (timer) {

@@ -17,0 +23,0 @@ currentResolver(path.discarded());

'use strict';
var _assign = require("babel-runtime/core-js/object/assign");
var _assign2 = _interopRequireDefault2(_assign);
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault2(_stringify);
var _getPrototypeOf = require("babel-runtime/core-js/object/get-prototype-of");
var _getPrototypeOf2 = _interopRequireDefault2(_getPrototypeOf);
var _setPrototypeOf = require("babel-runtime/core-js/object/set-prototype-of");
var _setPrototypeOf2 = _interopRequireDefault2(_setPrototypeOf);
var _create = require("babel-runtime/core-js/object/create");
var _create2 = _interopRequireDefault2(_create);
var _iterator = require("babel-runtime/core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault2(_iterator);
var _typeof3 = require("babel-runtime/helpers/typeof");
var _typeof4 = _interopRequireDefault2(_typeof3);
var _symbol = require("babel-runtime/core-js/symbol");
var _symbol2 = _interopRequireDefault2(_symbol);
var _defineProperty = require("babel-runtime/core-js/object/define-property");
var _defineProperty2 = _interopRequireDefault2(_defineProperty);
function _interopRequireDefault2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -10,3 +48,3 @@ value: true

for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;(0, _defineProperty2.default)(target, descriptor.key, descriptor);
}

@@ -18,6 +56,6 @@ }return function (Constructor, protoProps, staticProps) {

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
var _typeof = typeof _symbol2.default === "function" && (0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
};

@@ -70,3 +108,3 @@

throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}return call && (typeof call === "object" || typeof call === "function") ? call : self;
}return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof4.default)(call)) === "object" || typeof call === "function") ? call : self;
}

@@ -76,4 +114,4 @@

if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof4.default)(superClass)));
}subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
}

@@ -110,3 +148,3 @@

var _this = _possibleConstructorReturn(this, (FunctionTreeExecution.__proto__ || Object.getPrototypeOf(FunctionTreeExecution)).call(this));
var _this = _possibleConstructorReturn(this, (FunctionTreeExecution.__proto__ || (0, _getPrototypeOf2.default)(FunctionTreeExecution)).call(this));

@@ -157,3 +195,3 @@ _this.id = createUniqueId();

functionTree.emit('functionEnd', execution, funcDetails, payload);
throw new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' needs to be a path');
throw new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' needs to be a path');
} else if (isValidResult(result)) {

@@ -166,3 +204,3 @@ functionTree.emit('functionEnd', execution, funcDetails, payload);

functionTree.emit('functionEnd', execution, funcDetails, payload);
throw new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' is not a valid result');
throw new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' is not a valid result');
}

@@ -176,3 +214,3 @@ }).catch(function (result) {

} else if (funcDetails.outputs) {
var error = new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' needs to be a path');
var error = new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' needs to be a path');

@@ -186,3 +224,3 @@ errorCallback(error);

} else {
var _error = new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' is not a valid result');
var _error = new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' is not a valid result');

@@ -196,3 +234,3 @@ errorCallback(_error);

} else if (funcDetails.outputs) {
var error = new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' needs to be a path');
var error = new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' needs to be a path');

@@ -206,3 +244,3 @@ errorCallback(error);

} else {
var _error2 = new Error('The result ' + JSON.stringify(result) + ' from function ' + funcDetails.name + ' is not a valid result');
var _error2 = new Error('The result ' + (0, _stringify2.default)(result) + ' from function ' + funcDetails.name + ' is not a valid result');
errorCallback(_error2);

@@ -220,3 +258,3 @@ }

return [(0, _Execution2.default)(this, _Abort2.default), (0, _Input2.default)(), (0, _Path2.default)()].concat(this.functionTree.contextProviders).reduce(function (currentContext, contextProvider) {
var newContext = typeof contextProvider === 'function' ? contextProvider(currentContext, funcDetails, payload) : Object.assign(currentContext, contextProvider);
var newContext = typeof contextProvider === 'function' ? contextProvider(currentContext, funcDetails, payload) : (0, _assign2.default)(currentContext, contextProvider);

@@ -243,3 +281,3 @@ if (newContext !== currentContext) {

var _this2 = _possibleConstructorReturn(this, (FunctionTree.__proto__ || Object.getPrototypeOf(FunctionTree)).call(this));
var _this2 = _possibleConstructorReturn(this, (FunctionTree.__proto__ || (0, _getPrototypeOf2.default)(FunctionTree)).call(this));

@@ -246,0 +284,0 @@ _this2.cachedTrees = [];

"use strict";
var _defineProperty = require("babel-runtime/core-js/object/define-property");
var _defineProperty2 = _interopRequireDefault(_defineProperty);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -10,3 +16,3 @@ value: true

for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ("value" in descriptor) descriptor.writable = true;(0, _defineProperty2.default)(target, descriptor.key, descriptor);
}

@@ -13,0 +19,0 @@ }return function (Constructor, protoProps, staticProps) {

'use strict';
var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
var _defineProperty = require('babel-runtime/core-js/object/define-property');
var _defineProperty2 = _interopRequireDefault(_defineProperty);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -9,3 +23,3 @@ value: true

return function (context, funcDetails, payload) {
return Object.keys(extendedContext).reduce(function (context, key) {
return (0, _keys2.default)(extendedContext).reduce(function (context, key) {
if (context.debugger) {

@@ -49,3 +63,3 @@ (function () {

} else if (!(objKey in obj)) {
Object.defineProperty(obj, objKey, {
(0, _defineProperty2.default)(obj, objKey, {
get: function get() {

@@ -86,5 +100,5 @@ return contextValue[objKey];

// Go through keys original value and wrap any attached methods
context[key] = proxy(Object.keys(contextValue), contextValue, context[key]); // Object.keys(contextValue).reduce(proxy, context[key])
context[key] = proxy((0, _keys2.default)(contextValue), contextValue, context[key]); // Object.keys(contextValue).reduce(proxy, context[key])
// Go through proto
context[key] = proto ? proxy(Object.getOwnPropertyNames(proto), proto, context[key]) : context[key];
context[key] = proto ? proxy((0, _getOwnPropertyNames2.default)(proto), proto, context[key]) : context[key];
})();

@@ -91,0 +105,0 @@ } else {

'use strict';
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault(_stringify);
var _iterator = require("babel-runtime/core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault(_iterator);
var _typeof3 = require("babel-runtime/helpers/typeof");
var _typeof4 = _interopRequireDefault(_typeof3);
var _symbol = require("babel-runtime/core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -7,6 +25,6 @@ value: true

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
var _typeof = typeof _symbol2.default === "function" && (0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
};

@@ -18,3 +36,3 @@

var cache = [];
var returnValue = JSON.stringify(obj || {}, function (key, value) {
var returnValue = (0, _stringify2.default)(obj || {}, function (key, value) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null) {

@@ -21,0 +39,0 @@ if (cache.indexOf(value) === -1) {

'use strict';
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault2(_promise);
function _interopRequireDefault2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -20,3 +26,3 @@ value: true

context.execution.retry = function (payload) {
return new Promise(function (resolve) {
return new _promise2.default(function (resolve) {
(0, _executeTree2.default)(execution.staticTree, execution.runFunction, payload, resolve);

@@ -23,0 +29,0 @@ });

'use strict';
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault2(_keys);
var _stringify = require("babel-runtime/core-js/json/stringify");
var _stringify2 = _interopRequireDefault2(_stringify);
var _iterator = require("babel-runtime/core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault2(_iterator);
var _typeof3 = require("babel-runtime/helpers/typeof");
var _typeof4 = _interopRequireDefault2(_typeof3);
var _symbol = require("babel-runtime/core-js/symbol");
var _symbol2 = _interopRequireDefault2(_symbol);
function _interopRequireDefault2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -7,6 +29,6 @@ value: true

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
var _typeof = typeof _symbol2.default === "function" && (0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
};

@@ -26,3 +48,3 @@

var cache = [];
var returnValue = JSON.stringify(obj || {}, function (key, value) {
var returnValue = (0, _stringify2.default)(obj || {}, function (key, value) {
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null) {

@@ -98,3 +120,3 @@ if (cache.indexOf(value) === -1) {

}).map(function (arg) {
return padded(_chalk2.default.white(JSON.stringify(arg)), registeredFunctionTrees[id].logLevel);
return padded(_chalk2.default.white((0, _stringify2.default)(arg)), registeredFunctionTrees[id].logLevel);
})));

@@ -107,3 +129,3 @@ } else {

if (prevFunction && prevFunction.outputs) {
var chosenOutput = Object.keys(prevFunction.outputs).filter(function (outputKey) {
var chosenOutput = (0, _keys2.default)(prevFunction.outputs).filter(function (outputKey) {
if (prevFunction.outputs[outputKey].length && ( // Might be an array which is the first element

@@ -110,0 +132,0 @@ Array.isArray(prevFunction.outputs[outputKey][0]) && prevFunction.outputs[outputKey][0][0].functionIndex === functionDetails.functionIndex || prevFunction.outputs[outputKey][0].functionIndex === functionDetails.functionIndex)) {

'use strict';
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault2(_keys);
function _interopRequireDefault2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -25,3 +31,3 @@ value: true

if (functionDetails.outputs) {
context.path = Object.keys(functionDetails.outputs).reduce(function (output, outputPath) {
context.path = (0, _keys2.default)(functionDetails.outputs).reduce(function (output, outputPath) {
output[outputPath] = createNext(next, outputPath);

@@ -28,0 +34,0 @@

'use strict';
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _iterator = require("babel-runtime/core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault(_iterator);
var _typeof3 = require("babel-runtime/helpers/typeof");
var _typeof4 = _interopRequireDefault(_typeof3);
var _symbol = require("babel-runtime/core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {

@@ -7,6 +25,6 @@ value: true

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
var _typeof = typeof _symbol2.default === "function" && (0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : (0, _typeof4.default)(obj);
};

@@ -52,3 +70,3 @@

funcDetails.outputs = {};
Object.keys(outputs).forEach(function (key) {
(0, _keys2.default)(outputs).forEach(function (key) {
if (func.outputs && !~func.outputs.indexOf(key)) {

@@ -55,0 +73,0 @@ throw new Error('function-tree - Outputs object doesn\'t match list of possible outputs defined for function.');

'use strict';
const FunctionTree = require('./function-tree').default;
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var FunctionTree = require('./function-tree').default;
module.exports = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// TODO: Addd default context provider
const runTask = FunctionTree(options.providers);
return (task, payload) => {
return new Promise((resolve, reject) => {
const onEnd = (execution, result) => {
var runTask = FunctionTree(options.providers);
return function (task, payload) {
return new _promise2.default(function (resolve, reject) {
var onEnd = function onEnd(execution, result) {
runTask.off('error', onError);
resolve(result);
};
const onError = (error, execution, payload) => {
var onError = function onError(error, execution, payload) {
runTask.off('end', onEnd);

@@ -18,0 +24,0 @@ reject(error);

'use strict';
const get = require('get-value');
const set = require('set-value');
var get = require('get-value');
var set = require('set-value');
module.exports = (targetTemplate, valueTemplate) => {
module.exports = function (targetTemplate, valueTemplate) {
return function set(ctx) {
const value = getValue(ctx, valueTemplate);
var value = getValue(ctx, valueTemplate);
setValue(ctx, targetTemplate, value);

@@ -14,3 +14,3 @@ };

function isContextPath(value) {
const regexp = /^[a-z]+:/gi;
var regexp = /^[a-z]+:/gi;
return regexp.test(value);

@@ -17,0 +17,0 @@ }

'use strict';
const get = require('get-value');
var _keys = require('babel-runtime/core-js/object/keys');
module.exports = test => {
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var get = require('get-value');
module.exports = function (test) {
return function when(ctx) {
const value = getValue(ctx, test);
const path = getPath(ctx, value);
var value = getValue(ctx, test);
var path = getPath(ctx, value);
if (typeof path !== 'function') {
const paths = Object.keys(ctx.path).join(', ');
throw new Error(`Could not find a matching path for value "${ value }" in paths: ${ paths }`);
var paths = (0, _keys2.default)(ctx.path).join(', ');
throw new Error('Could not find a matching path for value "' + value + '" in paths: ' + paths);
}

@@ -31,3 +37,3 @@

function getPath(ctx, value) {
const truthy = isTruthy(ctx.path);
var truthy = isTruthy(ctx.path);
if (truthy) {

@@ -34,0 +40,0 @@ return value ? ctx.path.true : ctx.path.false;

'use strict';
const contentDisposition = require('content-disposition');
const getType = require('mime-types').contentType;
const isJSON = require('koa-is-json');
const escape = require('escape-html');
const typeis = require('type-is').is;
const statuses = require('statuses');
const assert = require('assert');
const extname = require('path').extname;
const _vary = require('vary');
var _stringify = require('babel-runtime/core-js/json/stringify');
module.exports = options => {
return (context, functionDetails, payload) => {
var _stringify2 = _interopRequireDefault(_stringify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var contentDisposition = require('content-disposition');
var getType = require('mime-types').contentType;
var isJSON = require('koa-is-json');
var escape = require('escape-html');
var typeis = require('type-is').is;
var statuses = require('statuses');
var assert = require('assert');
var extname = require('path').extname;
var _vary = require('vary');
module.exports = function (options) {
return function (context, functionDetails, payload) {
context.response = HttpResponse(payload);

@@ -30,3 +36,3 @@ return context;

}
const response = {
var response = {
get header() {

@@ -43,3 +49,3 @@ return response.headers;

assert(typeof code === 'number', 'status code must be a number');
assert(statuses[code], `invalid status code: ${ code }`);
assert(statuses[code], 'invalid status code: ' + code);
payload.reponse_meta._explicitStatus = true;

@@ -76,3 +82,3 @@ payload.response.statusCode = code;

const setType = !response.headers['content-type'];
var setType = !response.headers['content-type'];

@@ -117,4 +123,4 @@ // string

get length() {
const len = response.headers['content-length'];
const body = response.body;
var len = response.headers['content-length'];
var body = response.body;

@@ -132,3 +138,3 @@ if (len === null) {

if (isJSON(body)) {
return Buffer.byteLength(JSON.stringify(body));
return Buffer.byteLength((0, _stringify2.default)(body));
}

@@ -159,3 +165,3 @@ return;

response.type = 'text/html; charset=utf-8';
response.body = `Redirecting to <a href="${ url }">${ url }</a>.`;
response.body = 'Redirecting to <a href="' + url + '">' + url + '</a>.';
return;

@@ -166,3 +172,3 @@ }

response.type = 'text/plain; charset=utf-8';
response.body = `Redirecting to ${ url }.`;
response.body = 'Redirecting to ' + url + '.';
},

@@ -191,3 +197,3 @@ attachment: function attachment(filename) {

get lastModified() {
const date = response.get('last-modified');
var date = response.get('last-modified');
if (date) {

@@ -199,3 +205,3 @@ return new Date(date);

if (!/^(W\/)?"/.test(val)) {
val = `"${ val }"`;
val = '"' + val + '"';
}

@@ -208,3 +214,3 @@ response.set('etag', val);

get type() {
const type = response.get('content-type');
var type = response.get('content-type');
if (!type) {

@@ -216,3 +222,3 @@ return '';

is: function is(types) {
const type = response.type;
var type = response.type;
if (!types) {

@@ -238,3 +244,3 @@ return type || false;

} else {
for (const key in field) {
for (var key in field) {
response.set(key, field[key]);

@@ -241,0 +247,0 @@ }

'use strict';
const net = require('net');
const contentType = require('content-type');
const typeis = require('type-is');
const fresh = require('fresh');
const accepts = require('accepts');
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var net = require('net');
var contentType = require('content-type');
var typeis = require('type-is');
var fresh = require('fresh');
var accepts = require('accepts');
module.exports = function () {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return (context, functionDetails, payload) => {
return function (context, functionDetails, payload) {
if (payload.serverless) {

@@ -23,5 +29,5 @@ context.request = ServerlessRequest(payload, context.response);

function ServerlessRequest(payload, response) {
const headers = getHeaders(payload);
const accept = accepts({ headers: headers });
const request = {
var headers = getHeaders(payload);
var accept = accepts({ headers: headers });
var request = {
get header() {

@@ -34,6 +40,6 @@ return headers;

get url() {
return `${ request.origin }${ request.path }`;
return '' + request.origin + request.path;
},
get origin() {
return `${ request.protocol }://${ request.host }`;
return request.protocol + '://' + request.host;
},

@@ -48,3 +54,3 @@ get method() {

} catch (error) {
console.warn(`Unable to parse request body as json: ${ error.message }`);
console.warn('Unable to parse request body as json: ' + error.message);
}

@@ -64,3 +70,3 @@ }

get host() {
let host = request.get('x-forwarded-host') || request.get('host');
var host = request.get('x-forwarded-host') || request.get('host');
if (!host) {

@@ -72,3 +78,3 @@ return '';

get hostname() {
const host = request.host;
var host = request.host;
if (!host) return '';

@@ -78,4 +84,4 @@ return host.split(':')[0];

get fresh() {
const method = request.method;
const s = response.status;
var method = request.method;
var s = response.status;

@@ -96,7 +102,7 @@ // GET or HEAD for weak freshness validation only

get idempotent() {
const methods = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'];
var methods = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'];
return !!~methods.indexOf(request.method);
},
get charset() {
const type = request.get('content-type');
var type = request.get('content-type');
if (!type) return '';

@@ -107,3 +113,3 @@

get length() {
const len = request.get('content-length');
var len = request.get('content-length');
if (len === '') return;

@@ -113,3 +119,3 @@ return ~~len;

get protocol() {
const proto = request.get('x-forwarded-proto') || 'http';
var proto = request.get('x-forwarded-proto') || 'http';
return proto.split(/\s*,\s*/)[0];

@@ -121,7 +127,7 @@ },

get ips() {
const val = request.get('x-forwarded-for');
var val = request.get('x-forwarded-for');
return val ? val.split(/\s*,\s*/) : [];
},
get subdomains() {
const hostname = request.hostname;
var hostname = request.hostname;
if (net.isIP(hostname)) {

@@ -155,3 +161,3 @@ return [];

get type() {
const type = request.get('content-type');
var type = request.get('content-type');
if (!type) {

@@ -163,3 +169,3 @@ return '';

get: function get(field) {
const header = request.header;
var header = request.header;
switch (field = field.toLowerCase()) {

@@ -179,8 +185,8 @@ case 'referer':

function getHeaders(payload) {
const obj = payload.serverless.aws.event.headers;
const keys = Object.keys(obj);
const header = {};
let n = keys.length;
var obj = payload.serverless.aws.event.headers;
var keys = (0, _keys2.default)(obj);
var header = {};
var n = keys.length;
while (n--) {
const key = keys[n];
var key = keys[n];
header[key.toLowerCase()] = obj[key];

@@ -187,0 +193,0 @@ }

{
"name": "arnie",
"version": "0.2.5",
"version": "0.2.6",
"description": "Action hero for backends",

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

"babel-core": "^6.18.0",
"babel-preset-es2015-node4": "^2.1.0",
"babel-plugin-transform-runtime": "^6.15.0",
"babel-preset-es2015": "^6.18.0",
"rimraf": "^2.5.4",

@@ -45,0 +46,0 @@ "standard": "^8.5.0",

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