puddinheads-sanitize
v0.1.0
Published
Lightweight email and sensitive text sanitizer with a built-in POST /sanitize endpoint.
Maintainers
Readme
puddinheads-sanitize
Lightweight email and sensitive text sanitization for Node.js apps.
Quick start
npm install puddinheads-sanitizeExample usage
const { sanitize } = require("puddinheads-sanitize");
sanitize("My email is [email protected]");
// "My email is [REDACTED]"API endpoint
Start the built-in server:
npx puddinheads-sanitizeThen send a request to:
POST /sanitize
content-type: application/json
{
"text": "My email is [email protected]"
}Response example
{
"sanitized": "My email is [REDACTED]"
}Package API
sanitize(input, options?)
Redacts email addresses from a string.
Optional options:
replacement: override the default[REDACTED]placeholderpatterns: add extra strings orRegExpvalues to redact
createSanitizeHandler(options?)
Creates a Node HTTP handler for POST /sanitize.
Accepted JSON bodies:
{ "text": "My email is [email protected]" }or:
{ "input": "My email is [email protected]" }createSanitizeServer(options?)
Creates a Node HTTP server with the sanitize handler mounted.
