-
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
#102 into [email protected] 🐘 add logger support #131
Conversation
# Conflicts: # src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.test.ts # src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.ts # src/core/middlewares/notFoundMiddleware/notFoundMiddleware.test.ts # src/core/rest/createRestRoutes/createRestRoutes.test.ts # src/core/rest/createRestRoutes/createRestRoutes.ts # src/server/createGraphQLMockServer/createGraphQLMockServer.ts # src/server/createMockServer/createMockServer.ts # src/server/createRestMockServer/createRestMockServer.ts
…, update logger logic in createGraphQLRoutes
src/utils/helpers/logger/helpers/coloredString/getRestMethodColoredString.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callRequestLogger/callRequestLogger.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/date/formatUnixTimestamp/formatUnixTimestamp.ts
Outdated
Show resolved
Hide resolved
src/core/middlewares/requestInfoMiddleware/requestInfoMiddleware.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
const isValidGraphQLRequest = | ||
graphQLInput && | ||
graphQLInput.query && | ||
graphQLQuery?.operationType && | ||
graphQLQuery.operationName; | ||
request.graphQL = isValidGraphQLRequest | ||
? { | ||
operationType: graphQLQuery.operationType as GraphQLOperationType, | ||
operationName: graphQLQuery.operationName, | ||
variables: graphQLInput.variables | ||
} | ||
: null; |
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.
operationType и operationName в типе ResponseLogFunctionParams могут быть undefined, хотя по сути не могут
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.
почему не могут? request.graphQL?.operationType будет undefined т.к. graphQL === null
# Conflicts: # .eslintrc.js # src/core/graphql/createGraphQLRoutes/createGraphQLRoutes.ts # src/core/middlewares/notFoundMiddleware/notFoundMiddleware.ts # src/core/rest/createRestRoutes/createRestRoutes.ts # src/server/createGraphQLMockServer/createGraphQLMockServer.ts # src/server/createMockServer/createMockServer.ts # src/server/createRestMockServer/createRestMockServer.ts # src/utils/helpers/interceptors/callRequestInterceptor/callRequestInterceptor.test.ts # src/utils/types/graphql.ts # src/utils/types/rest.ts # src/utils/types/utils.ts
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
… add rewrite function
src/utils/helpers/logger/callRequestLogger/callRequestLogger.test.ts
Outdated
Show resolved
Hide resolved
…leware refactoring fix readme, add callResponseLogger tests, add statusCode in default response log
src/utils/helpers/logger/helpers/filterTokenValues/filterTokenValues.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/helpers/filterTokenValues/filterTokenValues.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
… and graphql interceptors, replace (.mock.calls.length).toBe() -> .toBeCalledTimes(), fix readme
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
src/utils/helpers/logger/callResponseLogger/callResponseLogger.ts
Outdated
Show resolved
Hide resolved
if (objectTokenOption) { | ||
acc[objectTokenName] = objectTokenValues[objectTokenName]; | ||
} |
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.
Может быть так, что body - это примитив, и тогда здесь код упадет
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.
если body будет примитивом, то мы же только один раз достанем из него ключ и он будет undefined. я код не смог сломать. Но на всякий добавил проверку, чтобы actual token тоже был объектом. мало ли потом стрельнет когда body будем глубоко логать
const tokenObjectOptionsFilterMode = resolveTokenObjectOptionsFilterMode(option); | ||
|
||
if (tokenObjectOptionsFilterMode === 'whitelist') { | ||
acc[name] = Object.entries(option).reduce((acc, [name, objectTokenOption]) => { |
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.
objectTokenOption
- А почему везде ушла приписка token, а тут осталась?
- Мб назвать тогда nestedOption? Раз сверху название просто option
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.
- поправил
- согл
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.
После этого я еще больше стал топить за no-shadow)))
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.
если ты про параметр name, то хз как его обозвать. это не nestedOptionName потому что name есть только у токенов и не nestedTokenName потому что nested может быть только option, а не токен
Resolves #102