Comparing version 0.2.11 to 0.2.12
@@ -41,3 +41,4 @@ 'use strict'; | ||
}).catch(function (error) { | ||
console.error(error); | ||
// TODO: Find a better way to make errors visible | ||
// console.error(error) | ||
cb(error, null); | ||
@@ -44,0 +45,0 @@ }); |
@@ -110,3 +110,5 @@ 'use strict'; | ||
var len = request.get('content-length'); | ||
if (len === '') return; | ||
if (len === '') { | ||
return; | ||
} | ||
return ~~len; | ||
@@ -178,2 +180,3 @@ }, | ||
var obj = payload.serverless.aws.event.headers; | ||
var body = payload.serverless.aws.event.body; | ||
var keys = (0, _keys2.default)(obj); | ||
@@ -186,3 +189,7 @@ var header = {}; | ||
} | ||
// https://github.com/jshttp/type-is/issues/5 | ||
if (!header['content-length'] && typeof body === 'string') { | ||
header['content-length'] = body.length; | ||
} | ||
return header; | ||
} |
{ | ||
"name": "arnie", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "Action hero for backends", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,3 +28,4 @@ const A = require('../') | ||
.catch((error) => { | ||
console.error(error) | ||
// TODO: Find a better way to make errors visible | ||
// console.error(error) | ||
cb(error, null) | ||
@@ -31,0 +32,0 @@ }) |
@@ -100,3 +100,5 @@ const net = require('net') | ||
const len = request.get('content-length') | ||
if (len === '') return | ||
if (len === '') { | ||
return | ||
} | ||
return ~~len | ||
@@ -169,2 +171,3 @@ }, | ||
const obj = payload.serverless.aws.event.headers | ||
const body = payload.serverless.aws.event.body | ||
const keys = Object.keys(obj) | ||
@@ -177,3 +180,7 @@ const header = {} | ||
} | ||
// https://github.com/jshttp/type-is/issues/5 | ||
if (!header['content-length'] && typeof body === 'string') { | ||
header['content-length'] = body.length | ||
} | ||
return header | ||
} |
@@ -14,27 +14,26 @@ const test = require('tape') | ||
aws: { | ||
event: { | ||
path: '/health', | ||
httpMethod: 'GET', | ||
headers: | ||
{ 'Accept': 'application/json', | ||
'Accept-Encoding': 'gzip, deflate, sdch, br', | ||
'Content-Type': 'application/json', | ||
'Transfer-Encoding': 'application/json', | ||
'Host': 'thal9f3ckh.execute-api.eu-central-1.amazonaws.com', | ||
'X-Forwarded-For': '37.24.113.159, 54.240.145.73', | ||
'X-Forwarded-Port': '443', | ||
'X-Forwarded-Proto': 'https' }, | ||
queryStringParameters: {test: '132'}, | ||
pathParameters: {test: '456'}, | ||
stageVariables: null, // TODO: Check how passed and test | ||
requestContext: | ||
{ stage: 'dev', | ||
requestId: 'cc00f484-9c75-11e6-8236-19d9426b7ebb', | ||
identity: | ||
{ sourceIp: '37.24.113.159' }, | ||
resourcePath: '/health', | ||
httpMethod: 'GET', | ||
apiId: 'thal9f3ckh' }, | ||
body: '{\n\t"foo": "BAR",\n\t"bar": 123\n}' | ||
}, | ||
event: { resource: '/webhook', | ||
path: '/webhook', | ||
httpMethod: 'POST', | ||
headers: { | ||
'Accept-Encoding': 'deflate, gzip', | ||
'Content-Type': 'application/json', | ||
'X-Forwarded-Port': '443', | ||
'Host': 'thal9f3ckh.execute-api.eu-central-1.amazonaws.com', | ||
'Via': '1.1 8008015354a3ca72f56c382a1d1cfe9f.cloudfront.net (CloudFront)' | ||
}, | ||
queryStringParameters: {test: '132'}, | ||
pathParameters: {test: '456'}, | ||
stageVariables: null, // TODO: Check how passed and test | ||
requestContext: { | ||
accountId: '756919022514', | ||
resourceId: 't086e5', | ||
stage: 'dev', | ||
requestId: 'e948cc68-a126-11e6-a651-c3f10ad62c96', | ||
identity: {}, | ||
resourcePath: '/webhook', | ||
httpMethod: 'POST', | ||
apiId: 'thal9f3ckh' | ||
}, | ||
body: '{"foo": "BAR", "bar": 123}' }, | ||
context: {} | ||
@@ -48,4 +47,4 @@ } | ||
// TODO: Add tests for all other api methods! | ||
t.equal(request.method, 'GET', 'should parse the method') | ||
t.equal(request.path, '/health', 'should parse the path') | ||
t.equal(request.method, 'POST', 'should parse the method') | ||
t.equal(request.path, '/webhook', 'should parse the path') | ||
t.deepEqual(request.query, {test: '132'}, 'should parse the query parameters') | ||
@@ -58,3 +57,3 @@ t.deepEqual(request.params, {test: '456'}, 'should parse the path parameters') | ||
t.deepEqual(request.body, {foo: 'BAR', bar: 123}, 'should parse a json body') | ||
t.equal(request.rawBody, '{\n\t"foo": "BAR",\n\t"bar": 123\n}', 'should provide raw body') | ||
t.equal(request.rawBody, '{"foo": "BAR", "bar": 123}', 'should provide raw body') | ||
} | ||
@@ -61,0 +60,0 @@ ], payload) |
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
171546
3958