
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
express-scrubbr
Advanced tools
Seamlessly serialize JSON data using TypeScript in express.
This middleware requires Scrubbr to be installed and setup.
npm i -S scrubbr
npm i -S express-scrubbr
Add middleware to your express app
import express from "express";
import Scrubbr from "scrubbr";
import scrubbrMiddleware from "express-scrubbr";
var app = express();
// Load typescript schema and set any scrubbr options
const scrubbr = new Scrubbr("./schema.ts");
app.use(scrubbrMiddleware(scrubbr));
Use it in your routes
app.get('/users', (req, res) => {
const userData = fetchDataHere();
resp.status(200)
.scrubbr('UserList') // serialize userData with the UserList typescript type
.send(userData);
}
You can pass scrubbr options at the route level:
resp
.status(200)
.scrubbr("UserList", { logLevel: LogLevel.DEBUG })
.send(userData);
You can also pass a custom scrubbr instance:
const customScrubbr = scrubbr.clone();
customScrubbr.addTypeSerializer("User", userTransformer);
resp.status(200).scrubbr("UserList", customScrubbr).send(userData);
The middleware will clone the scrubbr instance, so if you want to add global state you can do that through the express response locals object.
For example, adding the authenticated user to the global state:
app.use(scrubbrMiddleware(scrubbr));
// Auth middleware
app.use((req, res, next) => {
const user = ... // do authy stuff here.
// Access the scrubbr instance on the response locals object
res.locals.scrubbr.setGlobalContext({ user }, true);
})
FAQs
Serialization middleware using TypeScript as the schema.
The npm package express-scrubbr receives a total of 2 weekly downloads. As such, express-scrubbr popularity was classified as not popular.
We found that express-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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.