Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@connectedyard/restify-await-promise
Advanced tools
Restify Plugin to support promises and async/await
Converts restify routes to support async/await and returned promises. Works with Restify 4.x through 6.x. May work with Restify 7+.
#Supported Restify Versions
const restify = require('restify');
const restifyPromise = require('restify-await-promise');
const server = restify.createServer({
name: 'myapp',
version: '1.0.0'
});
//Allows you to manipulate the errors before restify does its work
const alwaysBlameTheUserErrorTransformer = {
transform: function( exceptionThrownByRoute ){
//Always blame the user
exceptionThrownByRoute.statusCode = 400;
return exceptionThrownByRoute;
}
}
const options = {
logger: yourLogger, //Optional: Will automatically log exceptions
errorTransformer: alwaysBlameTheUserErrorTransformer //Optional: Lets you add status codes
};
restifyPromise.install( server, options ); // Options is not required
// Async function, automatically calls send with the returned object and next
server.get('/lookup/:name', async function (req) {
return await SomePromise.work( req.parms.name );
});
// Promise function
server.get('/echo/:name', function (req) {
const params = req.params;
return Promise.resolve( { params } );
});
// Existing restify method
server.get('/echo2/:name', function (req, res, next) {
res.send(req.params);
next();
});
// Versioned Route with Restify 7+
server.get('/seek/:enlightenment', restifyPromise.asyncConditionalHandler([
{
version: "1.0.0",
handler: async function (req) {
const result = await searchFor( req.parms.enlightenment );
return result;
}
}
]));
server.listen(8080, function () {
console.log('%s listening at %s', server.name, server.url);
});
$ npm install --save restify-await-promise
FAQs
Restify Plugin to support promises and async/await
The npm package @connectedyard/restify-await-promise receives a total of 0 weekly downloads. As such, @connectedyard/restify-await-promise popularity was classified as not popular.
We found that @connectedyard/restify-await-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.