Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
httpexceptions
Advanced tools
Provide Exceptions for REST API based on Express.js.
This module lets you to throw an HTTPException quickly.
Some HTTP Exception are already implemented :
You can use HTTPException method to throw a custom Exception (see example).
Use npm install httpexceptions
.
var httpException = require('httpexception');
var express = require('express');
var app = express();
httpException.debug(true);
app.use(httpException.mime('application/json'));
app.use(httpException.paramsRequired());
// OR
// app.use(httpException.mime(['application/json', 'text/xml']));
app.get('/my/route/exception', function(req, res){
throw new httpException.BadRequest('Custom Message'); //Emit
// OR
// throw new httpException.HTTPException(510, 'Custom Message');
});
app.get('/my/route/params', function(req, res){
req.paramsRequired({
query:['id']
}); //throw a BadRequest exception if the parameters id isn't defined in queryParams
});
//at the end
//GlobalHandler middleware catch exception and send response to the client
app.use(httpException.globalHandler());
This module is written in Typescript. But don't use import HttpExceptions = require('httpexceptions')
instead of
var httpException = require('httpexception');
. It's little buggy because, Error type in typescript is declared as
variable / interface and when you import module, the compilator fail.
So, you can find file definition httpexceptions.d.ts
in the module.
/// <reference path="node_modules/httpexceptions/httpexceptions.d.ts" />
var httpException = require('httpexception');
Use npm test
.
FAQs
Provide exception for HTTP Rest API
The npm package httpexceptions receives a total of 0 weekly downloads. As such, httpexceptions popularity was classified as not popular.
We found that httpexceptions 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.