feat: add env boolean normalizer helper and slow query fingerprint logging#360
Merged
Chucks1093 merged 1 commit intoMay 29, 2026
Conversation
Adds a normalizeEnvBoolean() helper (issue accesslayerorg#342) that parses "true", "false", "1", "0", "yes", and "no" from env vars into a real boolean and throws EnvBooleanParseError for unrecognized values. Includes full unit test coverage of all accepted variants and error cases. Adds general-purpose slow database query logging to prisma.utils.ts (issue accesslayerorg#343): any query exceeding SLOW_QUERY_THRESHOLD_MS emits a warn-level structured log containing a normalized query fingerprint (model + operation + arg structure, no parameter values), elapsed time, and request ID. The threshold is configurable via env var (default 500ms). Closes accesslayerorg#342 Closes accesslayerorg#343 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@leojay-net Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
normalizeEnvBoolean(varName, value)helper insrc/utils/env-boolean.utils.tsthat normalises all common boolean string representations from environment config (true,false,1,0,yes,no) into a real boolean. ThrowsEnvBooleanParseErrorwith the var name and raw value included for any unrecognised input instead of silently defaulting.src/utils/prisma.utils.tsto emit awarn-level structured log whenever any database query exceedsSLOW_QUERY_THRESHOLD_MS. The log includes a normalised query fingerprint (model, operation, and arg structure with all leaf values replaced by?— no parameter values), elapsed time, and request ID. The threshold is configurable via the newSLOW_QUERY_THRESHOLD_MSenv var (default 500 ms).Changes
src/utils/env-boolean.utils.tsnormalizeEnvBoolean+EnvBooleanParseErrorsrc/utils/env-boolean.utils.test.tssrc/utils/prisma.utils.ts$allOperationssrc/config.schema.tsSLOW_QUERY_THRESHOLD_MSZod field (default 500).env.exampleSLOW_QUERY_THRESHOLD_MS=500Test plan
pnpm exec jest env-boolean— 28 tests pass covering every accepted variant (true/True/TRUE/1/yes/Yes/YES,false/False/FALSE/0/no/No/NO), whitespace trimming, unrecognised values (maybe,2,on,"", …), andEnvBooleanParseErrorproperty shapepnpm run lint— no new lint errorsAcceptance criteria
#342
EnvBooleanParseErrorrather than silently defaulting#343
SLOW_QUERY_THRESHOLD_MSemit awarn-level log withfingerprintandelapsedMs?)SLOW_QUERY_THRESHOLD_MSenv var)Closes #342
Closes #343
Closes #346
Closes #347