Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
scrubbr
Advanced tools
Readme
Serialize JSON data using TypeScript.
Serializing data sent from the webserver to the client shouldn't be hard. If you're already using TypeScript, you have everything you need. Scrubbr will use your TypeScript types to deeply transform and sanitize your data.
npm i -S scrubbr
The simplest example is to filter out sensitive data.
In this example we want to filter the email and password out of this sample data:
{
users: [
{
name: 'John Doe',
image: 'http://i.pravatar.cc/300',
email: 'donotspam@me.com',
password: 'xxxsecretxxx',
},
],
};
// schema.ts
type UserList = {
users: User[];
};
type User = {
name: string;
image: string;
};
import Scrubbr from 'scrubbr';
// PERFORMANCE NOTE: this is a synchronous call!
// Load early and cache to a shared variable.
const scrubbr = new Scrubbr('./schema.ts');
function api() {
const data = getUsers();
// Serialize the data based on the UserList type defined in schema.ts
return scrubbr.serialize('UserList', data);
}
{
"users": [
{
"name": "John Doe",
"image": "http://i.pravatar.cc/300"
}
]
}
To make things even easier in express, install the Scrubbr express middleware.
app.get('/users', (req, res) => {
const userData = fetchDataHere();
resp.status(200)
.scrubbr('UserList')
.send(userData);
}
Read the documentation to learn how do do more with Scrubbr.
FAQs
Serialize and sanitize JSON data using TypeScript.
We found that scrubbr 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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).