Repository navigation
Refactor: extract findUserOrThrow in AuthService, drop dead test vars - #101
Merged
Merged
Conversation
- AuthService: getProfile, updateSettings and updateProfile each repeated the same find-by-id + "User not found" check; move it into a private findUserOrThrow helper. Same query, same error. - MarkupToPdfReportGenerator: type the standalone browser variable. - Tests: remove an unused options object and an unused result variable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GTictqecCYiBSiCMj1RKN
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.
Part of buzz-code/ops#60
Scope
Weekly behavior-preserving tech-debt pass. Focus: code changed since 2026-11-07 (auth, jobs, mcp, report/PDF, s3, logging). No API, DTO, entity or schema change; no consumer action needed (no CONSUMER_CHANGES.md row).
Changes
auth/auth.service.ts:getProfile,updateSettingsandupdateProfileeach repeated the samefindOneBy({ id })+throw new Error('User not found')block. Moved into a privatefindUserOrThrow(userId). Same query, same error.utils/report/markup-to-pdf.generator.ts: typed the standalone browser variable (let browser: Browser | undefined), was implicitany.base-entity/__tests__/base-entity.service.spec.ts: removed an unusedoptionsobject.utils/report/__tests__/pdf-render.scope.spec.ts: removed an unusedresultvariable (call still awaited).Helper added
AuthService.findUserOrThrow(userId: number): Promise<User>(private,auth/auth.service.ts): load a user by id or throwUser not found.Not changed
AuthService.validateUser/registerUserreturn types fromPromise<any>toIAuthenticatedUser: tried, but it breaks existing test mocks (and likely consumer mocks), so left as is.app/__tests__/base-app.module.spec.ts:DefaultUserInitModuleis required but never asserted. Fixing it would mean changing what the test checks, so left out of this pass.Tests
Run in consumer layout (
server/shared), same as CI:yarn test95 suites / 904 tests passed;tsc --noEmitclean.yarn test95 suites / 904 tests passed;tsc --noEmitclean;--noUnusedLocalsshows only the test var noted above.Generated by Claude Code