4lessandrodev/ts-logs

Delete key and subkeys from request body

Closed this issue · 0 comments

Delete deep keys from body

On define on stackLog midleware to ignore key "password" ignore it wherever place it is present on root object or insider another object in body.

Example:

app.use(stackLog({ writeLocal: true, remove: [ "password" ] }));

If provide body like example below

req.body = { "password" : "12345", email: "test@mail.com" };

// On log result out. Removes the password

> {  "email": "test@mail.com" }

But when password is inside another object it does not works.

req.body = {  "data": { "password" : "12345", email: "test@mail.com"  } };

// On log result out. do not removes password because it is inside data object

> {  "data": { "password" : "12345", email: "test@mail.com"  }  }

Remove password wherever place it is.