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.2 to 0.2.3

33

lib/adapters/serverless.js

@@ -9,8 +9,10 @@ 'use strict';

return (event, context, cb) => {
// TODO: Check serverless callback signature
// TODO: Transorm input to arnie stanard input
arnie(task, event)
const input = createInput(event, context);
arnie(task, input)
// TODO: Transorm reponse from arnie stanard ouput to serverless
.then(result => {
cb(null, result);
if (typeof context.succeed === 'function') {
context.succeed(result.res);
}
cb(null, result.res);
}).catch(error => {

@@ -21,2 +23,23 @@ cb(error, null);

};
};
};
// TODO: Settle on arnie stanard input e.g. req
function createInput(event, context) {
return {
aws: {
event: event,
context: context
},
req: {
headers: event.headers,
method: event.method,
url: event.path // TODO: pass the complete url if possible
},
res: {
headers: {},
statusCode: undefined,
statusMessage: 200,
body: undefined
}
};
}

2

package.json
{
"name": "arnie",
"version": "0.2.2",
"version": "0.2.3",
"description": "Action hero for backends",

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

@@ -7,8 +7,10 @@ const A = require('../')

return (event, context, cb) => {
// TODO: Check serverless callback signature
// TODO: Transorm input to arnie stanard input
arnie(task, event)
const input = createInput(event, context)
arnie(task, input)
// TODO: Transorm reponse from arnie stanard ouput to serverless
.then((result) => {
cb(null, result)
if (typeof context.succeed === 'function') {
context.succeed(result.res)
}
cb(null, result.res)
})

@@ -21,1 +23,22 @@ .catch((error) => {

}
// TODO: Settle on arnie stanard input e.g. req
function createInput (event, context) {
return {
aws: {
event,
context
},
req: {
headers: event.headers,
method: event.method,
url: event.path // TODO: pass the complete url if possible
},
res: {
headers: {},
statusCode: undefined,
statusMessage: 200,
body: undefined
}
}
}

@@ -21,8 +21,18 @@ const test = require('tape')

const expectedReq = {
method: 'GET',
url: '/success',
headers: {}
}
const taskA = [
(ctx) => {
({input, path}) => {
t.deepEqual(
input.req,
expectedReq,
'should pass request information'
)
testExecution('taskA', 1)
return new Promise((resolve) => {
setTimeout(
() => resolve(ctx.path.goHere({someOutput: true})),
() => resolve(path.goHere({someOutput: true})),
50

@@ -55,3 +65,3 @@ )

serverless.request('/error', (error, result) => {
serverless.request({method: 'GET', path: '/error'}, (error, result) => {
t.equal(

@@ -64,8 +74,8 @@ error,

const expectedResult = {path: '/success', someOutput: true}
serverless.request('/success', (error, result) => {
const expectedResult = {someOutput: true}
serverless.request({method: 'GET', path: '/success'}, (error, result) => {
if (!error) {
t.deepEqual(
result,
expectedResult,
t.eqaul(
result.input.someOutput,
expectedResult.someOutput,
'should resolve successful execution with final output'

@@ -72,0 +82,0 @@ )

module.exports.setupServerless = (functions) => {
return {
request: (path, callback) => {
const fn = functions[path]
request: (options, callback) => {
const fn = functions[options.path]
if (typeof fn !== 'function') {
throw new Error(`No function for path ${path} defined!`)
throw new Error(`No function for path ${options.path} defined!`)
}
fn(
createEvent(path),
createEvent(options),
createContext(),

@@ -17,5 +17,7 @@ callback

function createEvent (path) {
function createEvent (options) {
return {
path
method: options.method,
path: options.path,
headers: {}
}

@@ -22,0 +24,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