@anabode/shared_rest_responder
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -0,0 +0,0 @@ module.exports = exports = RestResponder = { |
@@ -0,4 +1,6 @@ | ||
'use strict'; | ||
var WebRequest; | ||
/// Generic model for DTO from web requests | ||
/// transform web request into a useable object nad strips out the :hankey: | ||
module.exports = exports = WebRequest = { | ||
module.exports = WebRequest = { | ||
fullObject: function (input) { | ||
@@ -19,3 +21,3 @@ var _input = input; | ||
}, | ||
headerObject: function (input) { | ||
headerObject: function (input) { | ||
var _input = input; | ||
@@ -26,3 +28,3 @@ return { | ||
}, | ||
queryObject: function (input) { | ||
queryObject: function (input) { | ||
var _input = input; | ||
@@ -38,3 +40,15 @@ return { | ||
}; | ||
}, | ||
lambdaProxyObject: function (input) { | ||
var _input = input; | ||
return { | ||
header: _input.headers, | ||
// header: _.assign(_input.headers, _input.context), | ||
params: {}, | ||
pathProxy: _input.pathParameters.proxy.split('/'), | ||
query: _input.query, | ||
body: (_.isString(_input.body) ? JSON.parse(_input.body) : _input.body), | ||
method: _input.httpMethod | ||
}; | ||
} | ||
}; |
@@ -1,8 +0,9 @@ | ||
var _ = require('lodash'); | ||
module.exports = exports = WebResponse = { | ||
successResp: function(body, internalCode) { | ||
'use strict'; | ||
var _ = require('lodash'), WebResponse; | ||
module.exports = WebResponse = { | ||
successResp: function (body, internalCode) { | ||
var _body = body; | ||
var _internalCode = internalCode; | ||
if (_internalCode) { | ||
if (typeof(_body) === "undefined" || _.isNull(_body)) { | ||
if (_.isUndefined(_body) || _.isNull(_body)) { | ||
return { | ||
@@ -20,7 +21,6 @@ responseData: "emptyResponseReturnedObjectNotFound", | ||
errorResp: function (body, internalCode) { | ||
var _body = body; | ||
var _internalCode = internalCode; | ||
if(_internalCode){ | ||
if(typeof(_body) === "undefined" || _.isNull(_body)) { | ||
return { | ||
var _body = body, _internalCode = internalCode; | ||
if (_internalCode) { | ||
if (_.isUndefined(_body) || _.isNull(_body)) { | ||
return { | ||
responseData: "emptyResponseReturnedObjectNotFound", | ||
@@ -31,3 +31,3 @@ code: _internalCode | ||
return { | ||
responseData: _body, | ||
responseData: _body.message || _.toString(_body), | ||
code: _internalCode | ||
@@ -37,5 +37,6 @@ }; | ||
} else { | ||
//undefined error | ||
return { | ||
responseData: _body, | ||
code: "API9999x0" //undefined error | ||
responseData: _body.message || _.toString(_body), | ||
code: "API9999x0" | ||
}; | ||
@@ -42,0 +43,0 @@ } |
@@ -0,0 +0,0 @@ Version 2, December 2004 |
{ | ||
"name": "@anabode/shared_rest_responder", | ||
"version": "1.0.4", | ||
"description": "web response model class", | ||
"version": "1.0.5", | ||
"description": "web response model class, including AWS API Gateway Proxy request model into Lambda", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
3636
94