Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
NodeJS errors for cool kids
Ouch is a NodeJS implementation of PHP's Whoops library. It's not an exact port of Whoops, but implements similar functionality and uses same front end resources in some of its error handlers. It is an error handler base/framework for NodeJs. Out-of-the-box, it provides a pretty error interface that helps you debug your web projects, but at heart it's a simple yet powerful stacked error handling system.
The source is available for download from GitHub. Alternatively, you can install using Node Package Manager (npm):
npm install ouch
// With PrettyPageHandler
http.createServer(function nsjfkj(req, res){
if (req.url === '/favicon.ico') {
res.writeHead(200, {'Content-Type': 'image/x-icon'} );
res.end();
return;
}
var d = domain.create();
d.on('error', function(e){
var ouchInstance = (new Ouch).pushHandler(
new Ouch.handlers.PrettyPageHandler('orange', null, 'sublime')
);
ouchInstance.handleException(e, req, res, function (output) {
console.log('Error handled properly')
});
});
d.run(function(){
// your application code goes here
});
}).listen('1338', 'localhost');
// With custom callback
var ouchInstance = (new Ouch).pushHandler(
function(next, exception, inspector, run, request, response){
// custom handler logic
next();
});
ouchInstance.handleException(e, req, res, function (output) {
console.log('Error handled properly')
});
For more options, have a look at the example files in examples to get a feel for how things work. Also take a look at the API Documentation and the list of available handlers below.
Ouch currently ships with the following built-in handlers, available in the require("ouch").handlers
namespace:
PrettyPageHandler
- Shows a pretty error page when something goes pants-upJsonResponseHandler
- Process errors and returns information on them as a JSON string.CallbackHandler
- Wraps a callable as a handler. You do not need to use this handler explicitly, Ouch will automatically wrap any callable you pass to ouchInstance.pushHandler
.- Add more handlers.
Ouch is open-sourced software licensed under the MIT license.
FAQs
Javascript error handling for cool kids
The npm package ouch receives a total of 17,250 weekly downloads. As such, ouch popularity was classified as popular.
We found that ouch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.