-
Notifications
You must be signed in to change notification settings - Fork 5
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
Adiciona propriedade propMaxLength ao httpConf #57
Conversation
f8700c2
to
71c5296
Compare
2d6836c
to
f1f3f88
Compare
f1f3f88
to
9af02c0
Compare
@itsdaiego consegue adicionar uns testes unitários para cobrir as linhas restantes desse arquivo? |
9af02c0
to
a30286f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boa 👏 💯
Eu dei uma olhada, e se eu entendi bem as linhas que não estão sendo testadas, não é algo fácil de fazer agora, eu tentei testar o módulo de response inteiro e não consegui (precisaria mudar bastante o código e demoraria beem mais pra lançar essa feature) =\ mas concordo que diminuir o coverage seja algo a ser evitado, só que realmente acho que o esforço de deixar tudo 100% não é algo "trivial" (ou estou superestimando a dificuldade) |
709d25a
to
0ddd3d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Na descrição o PR vc colocou que se a URL passar do tamanho, a queryString será ignorada, mas no código, vc está dando um substring
na URL e concatenando *
.
Senti falta dessa informação no README
src/utils.js
Outdated
const filterLargeProp = (object, prop, propLengthLimit) => { | ||
if (!object[prop]) return | ||
|
||
return JSON.stringify(object[prop]).length > propLengthLimit ? {} : object[prop] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E se object[prop]
for um array mto grande, não deveríamos retornar []
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não sei se entendi, object[prop]
retorna um objeto, eu converto para uma string e vejo se o length excede ao limite, o único array que existe é o propsToLog mas isso fica no src/[request/response]-logger.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se você diz de colocar um limite para o tamanho da string, o que você sugere 🙃 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nesse ternário aqui JSON.stringify(object[prop]).length > propLengthLimit ? {} : object[prop]
, vc retorna sempre um objeto vazio ({}
) se passar o tamanho limite. Se for um array, não deveria ser []
caso passe o tamanho ?
Boa, foi uma alteração sugerida pelo MC em um comentário acima... ai acabei esquecendo, vou alterar, valeu! =) |
0ddd3d5
to
f942391
Compare
const env = pickProperties(process.env, propsToLog) | ||
|
||
const resProps = pickProperties(res, propsToLog) | ||
resProps.body = filterLargeProp(resProps, 'body', propMaxLength.body) | ||
reqProps.url = filterLargeUrl(reqProps.url, propMaxLength.url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reqProps.url = filterLargeUrl(reqProps.url, propMaxLength.url) | |
if (propMaxLength.url) { | |
reqProps.url = filterLargeUrl(reqProps.url, propMaxLength.url) | |
} |
b7cec20
to
7a51bb7
Compare
Description
Add
maxLengthProp
property that will handle the max character length for a given attribute.Currently there are two main use cases:
1 - When the body attribute exceeds it's limit:
it will be replaced by:
body: { }
2 - When the url attribute exceeds it's limit:
/myurl?prop1=value1&prop2=value2
it will be replaced by:
/myurl?prop1***
(just an example, since it may vary depending on the url's limit)