Comparing version 0.1.3 to 0.1.4
@@ -13,3 +13,7 @@ 'use strict'; | ||
exports.default = (...args) => { | ||
exports.default = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
let paths, contentTypes; | ||
@@ -16,0 +20,0 @@ |
@@ -7,3 +7,5 @@ 'use strict'; | ||
exports.default = function (methods, origin = '*') { | ||
exports.default = function (methods) { | ||
let origin = arguments.length <= 1 || arguments[1] === undefined ? '*' : arguments[1]; | ||
return function cors(ctx) { | ||
@@ -10,0 +12,0 @@ let allowedOrigin = origin; |
@@ -7,3 +7,7 @@ "use strict"; | ||
exports.default = function (...args) { | ||
exports.default = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return function fail(ctx) { | ||
@@ -10,0 +14,0 @@ ctx.throw(...args); |
@@ -7,7 +7,7 @@ "use strict"; | ||
exports.default = (...args) => { | ||
let headers = args[0]; | ||
if (args.length > 1) { | ||
exports.default = function () { | ||
let headers = arguments.length <= 0 ? undefined : arguments[0]; | ||
if (arguments.length > 1) { | ||
headers = { | ||
[args[0]]: args[1] | ||
[arguments.length <= 0 ? undefined : arguments[0]]: arguments.length <= 1 ? undefined : arguments[1] | ||
}; | ||
@@ -14,0 +14,0 @@ } |
@@ -7,9 +7,9 @@ 'use strict'; | ||
exports.default = function (...args) { | ||
exports.default = function () { | ||
let paths; | ||
if (args.length === 1) { | ||
paths = args[0]; | ||
} else if (args.length === 2) { | ||
if (arguments.length === 1) { | ||
paths = arguments.length <= 0 ? undefined : arguments[0]; | ||
} else if (arguments.length === 2) { | ||
paths = { | ||
[args[0]]: args[1] | ||
[arguments.length <= 0 ? undefined : arguments[0]]: arguments.length <= 1 ? undefined : arguments[1] | ||
}; | ||
@@ -23,4 +23,4 @@ } else { | ||
return { | ||
path, | ||
keys, | ||
path: path, | ||
keys: keys, | ||
regexp: (0, _pathToRegexp2.default)(path, keys), | ||
@@ -27,0 +27,0 @@ sanitizedKeys: keys.map(sanitizeRouteKey) |
@@ -7,3 +7,5 @@ "use strict"; | ||
exports.default = function (statusCode = 200) { | ||
exports.default = function () { | ||
let statusCode = arguments.length <= 0 || arguments[0] === undefined ? 200 : arguments[0]; | ||
return function status(ctx) { | ||
@@ -10,0 +12,0 @@ ctx.response.status = statusCode; |
@@ -12,3 +12,5 @@ 'use strict'; | ||
function middleware(taskDefinitions, config = {}) { | ||
function middleware(taskDefinitions) { | ||
let config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
const tasks = Object.keys(taskDefinitions).map(key => (0, _task.createTask)(taskDefinitions[key])); | ||
@@ -24,3 +26,3 @@ | ||
return function (_x, _x2) { | ||
return function (_x2, _x3) { | ||
return _ref.apply(this, arguments); | ||
@@ -27,0 +29,0 @@ }; |
@@ -9,6 +9,13 @@ 'use strict'; | ||
let runTask = exports.runTask = (() => { | ||
var _ref = _asyncToGenerator(function* (task, ctx = {}, ...args) { | ||
var _ref = _asyncToGenerator(function* (task) { | ||
let ctx = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if (!ctx.input) { | ||
ctx.input = {}; | ||
} | ||
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
for (const action of task.actions) { | ||
@@ -36,3 +43,3 @@ const output = yield action.fn(ctx, ...args); | ||
return function runTask(_x, _x2, _x3) { | ||
return function runTask(_x2, _x3, _x4) { | ||
return _ref.apply(this, arguments); | ||
@@ -43,4 +50,11 @@ }; | ||
let runTasks = exports.runTasks = (() => { | ||
var _ref2 = _asyncToGenerator(function* (tasks, ctx = {}, ...args) { | ||
var _ref2 = _asyncToGenerator(function* (tasks) { | ||
let ctx = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
const output = {}; | ||
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
for (const task of tasks) { | ||
@@ -53,3 +67,3 @@ Object.assign(output, (yield runTask(task, ctx, ...args))); | ||
return function runTasks(_x4, _x5, _x6) { | ||
return function runTasks(_x6, _x7, _x8) { | ||
return _ref2.apply(this, arguments); | ||
@@ -71,3 +85,5 @@ }; | ||
function createTask(definition, task = { actions: [] }) { | ||
function createTask(definition) { | ||
let task = arguments.length <= 1 || arguments[1] === undefined ? { actions: [] } : arguments[1]; | ||
if (!Array.isArray(definition)) throw new Error('Task definition should be an array.'); | ||
@@ -100,5 +116,5 @@ | ||
return { | ||
fn, | ||
fn: fn, | ||
outputs: {}, | ||
displayName | ||
displayName: displayName | ||
}; | ||
@@ -105,0 +121,0 @@ } |
@@ -18,3 +18,5 @@ 'use strict'; | ||
function Arnie(config = {}) { | ||
function Arnie() { | ||
let config = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
const myTasks = []; | ||
@@ -26,11 +28,11 @@ | ||
arnie.addTask = (...args) => { | ||
arnie.addTask = function () { | ||
let name, task; | ||
switch (args.length) { | ||
switch (arguments.length) { | ||
case 2: | ||
name = args[0]; | ||
task = args[1]; | ||
name = arguments.length <= 0 ? undefined : arguments[0]; | ||
task = arguments.length <= 1 ? undefined : arguments[1]; | ||
break; | ||
case 1: | ||
task = args[0]; | ||
task = arguments.length <= 0 ? undefined : arguments[0]; | ||
break; | ||
@@ -54,3 +56,7 @@ default: | ||
arnie.doIt = (() => { | ||
var _ref = _asyncToGenerator(function* (...args) { | ||
var _ref = _asyncToGenerator(function* () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
let result = {}; | ||
@@ -77,3 +83,3 @@ switch (args.length) { | ||
return function (_x) { | ||
return function (_x2) { | ||
return _ref.apply(this, arguments); | ||
@@ -80,0 +86,0 @@ }; |
{ | ||
"name": "arnie", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Action hero for backends", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"babel-eslint": "6.1.2", | ||
"babel-preset-es2015-node6": "0.3.0", | ||
"babel-preset-es2015-node5": "1.2.0", | ||
"babel-preset-stage-3": "6.11.0", | ||
@@ -36,0 +36,0 @@ "babel-register": "6.11.6", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51787
1869