{"_id":"@amidoltd/shared-req-res-handler","_rev":"5-c6e856cb8f2083f6d1c819c76860e030","name":"@amidoltd/shared-req-res-handler","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.1":{"name":"@amidoltd/shared-req-res-handler","version":"1.0.1","description":"web response/request model classes for router's in express like framework","main":"index.js","dependencies":{"lodash":"^4.17.4"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"DNitsch"},"license":"WTFPL","_id":"@amidoltd/shared-req-res-handler@1.0.1","_npmVersion":"5.7.1","_nodeVersion":"9.6.1","_npmUser":{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},"dist":{"integrity":"sha512-ypnJS1dqHuS+GzJpL7j6nj2wx7ssU4T70o4ZgQDzeZMvGokAkKrJkjjvqxZo6LfoGnoDPb1P9qjteGsaNmAx6g==","shasum":"dcc617fe1f33eb78f25572f18a08a97a30aa4b45","tarball":"https://registry.npmjs.org/@amidoltd/shared-req-res-handler/-/shared-req-res-handler-1.0.1.tgz","fileCount":6,"unpackedSize":4418,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD7jx643GakYdatDCHTyFLVeJR68I42AAXJnxuKE87AqwIgD5WbotIFXU3ZYE2TfRCvOv+a+s5bY8Xki0x9pA3SWUg="}]},"maintainers":[{"name":"amido","email":"billing@amido.com"},{"name":"amido-appveyor","email":"billing@amido.com"},{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},{"name":"scriptic","email":"si@siland.co.uk"},{"name":"usmanj","email":"usman.jamil@live.co.uk"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shared-req-res-handler_1.0.1_1521539785724_0.8890539394692041"},"_hasShrinkwrap":false},"1.0.2":{"name":"@amidoltd/shared-req-res-handler","version":"1.0.2","description":"web response/request model classes for router's in express like framework","main":"index.js","dependencies":{"lodash":"^4.17.4"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"DNitsch"},"license":"WTFPL","_id":"@amidoltd/shared-req-res-handler@1.0.2","_npmVersion":"5.7.1","_nodeVersion":"9.6.1","_npmUser":{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},"dist":{"integrity":"sha512-axqkR5Kf0sNE2Rc6mxp2wR1Ok7r0r5JOxvgJrYw1gMy2aUbyNxjO8G3Xi76eYCxAYzEJ+HVLQyrfz89b0fP+cA==","shasum":"1aee081e8f10f5474179220fec34f957b2e212d8","tarball":"https://registry.npmjs.org/@amidoltd/shared-req-res-handler/-/shared-req-res-handler-1.0.2.tgz","fileCount":6,"unpackedSize":6147,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDmtnIYWRSiiZ2RwaB1IqvHZ7ltaPlZR3rUbFl6+iJ9UgIhAPB3gVvx/gcQX5OEaJ39aJ/fgf2NCy3NWc5JLAd/oY6G"}]},"maintainers":[{"name":"amido","email":"billing@amido.com"},{"name":"amido-appveyor","email":"billing@amido.com"},{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},{"name":"scriptic","email":"si@siland.co.uk"},{"name":"usmanj","email":"usman.jamil@live.co.uk"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shared-req-res-handler_1.0.2_1521626514204_0.8336216757498762"},"_hasShrinkwrap":false},"1.0.3":{"name":"@amidoltd/shared-req-res-handler","version":"1.0.3","private":false,"description":"web response/request model classes for router's in express like framework","main":"index.js","dependencies":{"lodash":"^4.17.4"},"devDependencies":{},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"DNitsch"},"license":"WTFPL","_id":"@amidoltd/shared-req-res-handler@1.0.3","_npmVersion":"5.7.1","_nodeVersion":"9.6.1","_npmUser":{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},"dist":{"integrity":"sha512-JmdvenPgMVlhBKBuLbWyPyragW90kUCGZ0yJuJSdPtG82HDxzw6eiJJExJG7MPsgUm6i7I27RW9RymnRUzZ2Gw==","shasum":"18033c2c80646457dbab8aad2f84bc2712037c95","tarball":"https://registry.npmjs.org/@amidoltd/shared-req-res-handler/-/shared-req-res-handler-1.0.3.tgz","fileCount":6,"unpackedSize":6167,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICbvA412GpncXmE92Fdngwprpe5bo2SKUCXXqrjwEs7dAiEAkQm3tyjLr9oXbSDkkAwVrO6GVKnyar16+m7X5v6slP0="}]},"maintainers":[{"name":"amido","email":"billing@amido.com"},{"name":"amido-appveyor","email":"billing@amido.com"},{"name":"dnitsch","email":"nitschneiderd@googlemail.com"},{"name":"scriptic","email":"si@siland.co.uk"},{"name":"usmanj","email":"usman.jamil@live.co.uk"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shared-req-res-handler_1.0.3_1521735419335_0.10223774215280268"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-20T09:56:25.724Z","1.0.1":"2018-03-20T09:56:25.782Z","modified":"2022-04-04T13:48:33.719Z","1.0.2":"2018-03-21T10:01:54.258Z","1.0.3":"2018-03-22T16:16:59.442Z"},"maintainers":[{"email":"billing@amido.com","name":"amido"},{"email":"si@siland.co.uk","name":"scriptic"},{"email":"usman.jamil@live.co.uk","name":"usmanj"},{"email":"billing@amido.com","name":"amido-appveyor"}],"description":"web response/request model classes for router's in express like framework","author":{"name":"DNitsch"},"license":"WTFPL","readme":"# Shared Rest Request/Response parser\n\nCan be used with any web framework like express, should be used to strip out any meta data in the request object, allowing for quick access to headers, body, params, query objects\n\n#### installation\n```npm i @amidoltd/shared-req-res-handler```\n\n#### sample usage \n\n##### full request object parsed\n\n```js\nvar RestModel = require('@amidoltd/shared-req-res-handler');\nvar SomeFoo = require('./someFoo');\n\n/**\n * sample PUT request\n */\nrouter.post('/:mandatoryPathParam/:optionalPathParam?', function (req, res) {\n    this._req = req;\n    // fullObject will parse the entire request and strip out all properties except body, headers, params, query\n    var someFoo = new SomeFoo(RestModel.Reqst.fullObject(this._req));\n    someFoo.methodRequiringFullRequestObject((e, d) => {\n        if (e) {\n            res.statusCode = 500;\n            res.send(RestModel.Resp.errorResp(e, \"ANSIBLE160x5\"));  // TODO stringify error response on app side\n            res.end();\n        } else {\n            res.statusCode = 200;\n            res.send(RestModel.Resp.successResp(d));\n            res.end();\n        }\n    });\n});\n```\n###### params only \n\n```js\nvar RestModel = require('@amidoltd/shared-req-res-handler');\nvar SomeFoo = require('./someFoo');\n\n/**\n * sample PUT request\n */\nrouter.put('/:mandatoryPathParam/:optionalPathParam?', function (req, res) {\n    this._req = req;\n    // params will parse the params of request and strip out all other properties\n    var someFoo = new SomeFoo(RestModel.Reqst.fullObject(this._req));\n    someFoo.methodRequiringParamsOfTheRequestOnly((e, d) => {\n        if (e) {\n            res.statusCode = 500;\n            res.send(RestModel.Resp.errorResp(e, \"ANSIBLE160x5\"));  // TODO stringify error response on app side\n            res.end();\n        } else {\n            res.statusCode = 200;\n            res.send(RestModel.Resp.successResp(d));\n            res.end();\n        }\n    });\n});\n```\n\n###### request details\n```js\nvar RestModel = require('@amidoltd/shared-req-res-handler');\nvar requestParsed = RestModel.Reqst.fullObject(this._req);\n\nconsole.log(requestParsed);\n{   \n    body: {},\n    params: {},\n    headers: {},\n    query: {}\n}\n```\n\n#### Response Parser\nThis will create a unified response Model to be consumed in client apps\n\n - on success returning an object\n```js\n{ \n    responseData: {}\n}\n```\n\n - on success returning an array\n```js\n{ \n    responseData: [{}]\n}\n```\n\n - on success returning a string\n```js\n{ \n    responseData: \"\"\n}\n```\n\n - on error returns an error object and a code to allow for \n```js\n{ \n    responseData: {},\n    code: \"\"\n}\n```\n------- \n##### RELEASE NOTES\n - 1.0.2 \n    * \n    * \n##### TODO\n * improve docs","readmeFilename":"README.md"}