
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
jason-parse
Advanced tools
JSON to ES6 class object converter middleware for express
Jason uses the ES6 Reflect api, which requires at least Node.js version 6.4.0
npm install jason-parse
So first we define a basic model which requries an empty constructor that takes in parameter ...args
class User {
constructor(...args){}
get name() {
return this.name;
}
set name(newName) {
this.name = newName;
}
}
module.exports = User;
When you POST json to the express server, send it to the parameter entity so that the middleware can parse it
Now for our express routes that we want to use this middleware on:
const routes = require('express').Router();
const User = require('./User');
const jason = require('../index');
routes.post('/<name>', jason.single(User, 'user'), function(req, res) {
//req.body.user contains the parse entity from '{"name":"foo"}'
});
routes.post('/<name>', jason.array(User, 'users'), function(req, res) {
//req.body.users contains an array of the parsed entities '[{"name":"foo"},{"name","bar"}]'
});
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
JSON to ES6 class converter middleware for express
We found that jason-parse 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.