
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@amidoltd/shared-req-res-handler
Advanced tools
web response/request model classes for router's in express like framework
Can 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
npm i @amidoltd/shared-req-res-handler
var RestModel = require('@amidoltd/shared-req-res-handler');
var SomeFoo = require('./someFoo');
/**
* sample PUT request
*/
router.post('/:mandatoryPathParam/:optionalPathParam?', function (req, res) {
this._req = req;
// fullObject will parse the entire request and strip out all properties except body, headers, params, query
var someFoo = new SomeFoo(RestModel.Reqst.fullObject(this._req));
someFoo.methodRequiringFullRequestObject((e, d) => {
if (e) {
res.statusCode = 500;
res.send(RestModel.Resp.errorResp(e, "ANSIBLE160x5")); // TODO stringify error response on app side
res.end();
} else {
res.statusCode = 200;
res.send(RestModel.Resp.successResp(d));
res.end();
}
});
});
var RestModel = require('@amidoltd/shared-req-res-handler');
var SomeFoo = require('./someFoo');
/**
* sample PUT request
*/
router.put('/:mandatoryPathParam/:optionalPathParam?', function (req, res) {
this._req = req;
// params will parse the params of request and strip out all other properties
var someFoo = new SomeFoo(RestModel.Reqst.fullObject(this._req));
someFoo.methodRequiringParamsOfTheRequestOnly((e, d) => {
if (e) {
res.statusCode = 500;
res.send(RestModel.Resp.errorResp(e, "ANSIBLE160x5")); // TODO stringify error response on app side
res.end();
} else {
res.statusCode = 200;
res.send(RestModel.Resp.successResp(d));
res.end();
}
});
});
var RestModel = require('@amidoltd/shared-req-res-handler');
var requestParsed = RestModel.Reqst.fullObject(this._req);
console.log(requestParsed);
{
body: {},
params: {},
headers: {},
query: {}
}
This will create a unified response Model to be consumed in client apps
{
responseData: {}
}
{
responseData: [{}]
}
{
responseData: ""
}
{
responseData: {},
code: ""
}
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.