Skip to content

Commit 02d58b4

Browse files
committed
chore: remove response fileting as this should be delegated to fastify schema validators
1. Fastify's schema validation and serialization already do strong schem validation. 1. Appllying blanket filters will make code brittle (might miss variations), can have performance impacts, and can cause unexpected data loss making ti hard to debug on where the data sent was filtered.
1 parent bac8b15 commit 02d58b4

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

src/server.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,6 @@ server.register(rateLimit, {
5454
}
5555
});
5656

57-
// Response Sanitization
58-
function sanitizeResponse(data) {
59-
const sensitiveFields = ['password', 'token', 'secret', 'key', 'auth'];
60-
if (typeof data === 'object' && data !== null) {
61-
const sanitized = {...data};
62-
Object.keys(sanitized).forEach(key => {
63-
if (sensitiveFields.includes(key.toLowerCase())) {
64-
delete sanitized[key];
65-
}
66-
});
67-
return sanitized;
68-
}
69-
return data;
70-
}
71-
72-
server.addHook('preSerialization', (request, reply, payload, done) => {
73-
done(null, sanitizeResponse(payload));
74-
});
75-
7657
// Global error handler with correlation ID
7758
server.setErrorHandler((error, request, reply) => {
7859
const errorLog = {

0 commit comments

Comments
 (0)