Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add an optional callback containing all sanitised values #3

Open
RobTheFiveNine opened this issue Oct 1, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@RobTheFiveNine
Copy link
Owner

RobTheFiveNine commented Oct 1, 2022

Currently, there is an optional callback that can be specified (onClean) which will be called every time a value is sanitised. There may, however, be scenarios in which a callback would be preferred which is invoked once after the entire process is finished.

This callback would contain an array of objects that detail the same information as the existing callback for each sanitisation that occurred (object path, key, value).

In practise, its usage by the end user should look something like this:

const express = require('express');
const nosqlSanitizer = require('express-nosql-sanitizer');

const app = express();
app.use(nosqlSanitizer({
  onClean: (objectPath, key, value) => {
    console.log('A single item has been sanitised');
    console.log(objectPath, key, value);
  },
  onComplete: (sanitizations) => {
    console.log('All items have been sanitised');
    sanitizations.forEach((s) => {
      console.log(s.objectPath, s.key, s.value);
    });
  },
}));
@RobTheFiveNine RobTheFiveNine added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant