Align `src/common/` barrel exports and remove duplicate guard implementations
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- nodejs, typescript
Research direction
Start with the guard registrations in src/app.module.ts around lines 306-321, then locate both copies of kyc.guard.ts and roles.decorator.ts under src/. Run the duplicate-filename scan from the issue and check the existing scripts/check-kyc-guard-coverage.js to see how coverage is measured. Done means each guard exists once, the registration order is unchanged, and npm run test:kyc-guard-scan, npx tsc --noEmit and npm test all pass. Choosing the canonical copy and reorganising src/common/ needs maintainer input first.
Written by the indexing model from the issue text.
Description
Problem
src/common/ is the largest directory in the repository at 80 TypeScript files, and it holds more than "common utilities" in the conventional sense: guards, pipes, interceptors, filters, pagination, caching, database helpers, and middleware all live here. There are 12 index.ts barrel files scattered across src/ with no consistent convention, and duplicate filenames across modules include roles.decorator.ts and kyc.guard.ts (each appearing twice).
There is history here: issue #3, "Eliminate Duplicate Guard Implementations Across common/", is closed, and scripts/check-kyc-guard-coverage.js exists specifically to check KYC guard coverage (wired as npm run test:kyc-guard-scan). So the maintainers have already been fighting duplicate guards — this suggests the pattern has partially recurred.
Why it matters
Guards are security-relevant, and two copies of kyc.guard.ts or roles.decorator.ts mean the one that is actually registered is not discoverable by reading a name. src/app.module.ts:306-321 registers four global guards by class, so a maintainer has to trace each import to know which file won.
At 80 files, src/common/ is also hard to navigate, which makes it a frequent source of "where does this go?" questions — the kind of thing that generates low-quality duplicate utilities, compounding the problem.
Suggested Direction
-
Re-run the duplicate scan and publish the current list, since issue #3 was closed some time ago:
Get-ChildItem src -Recurse -Filter *.ts | Group-Object Name | Where-Object Count -gt 1Confirmed duplicates include
rebalancing.service.ts,profiling.service.ts,profiling.controller.ts,portfolio.controller.ts,roles.decorator.ts,kyc.guard.ts,email.service.ts,audit-log.entity.ts, andportfolio.module.ts. -
Consolidate
src/common/by concern. A structure likesrc/common/{guards,pipes,filters,interceptors,middleware,pagination,cache,database,utils}/would make the ownership obvious and prevent the sprawl. Include anindex.tsper subdirectory. -
For each duplicate guard or decorator, pick the registered one and delete the other, or convert the second into a thin re-export so existing imports keep working. Confirm which is actually registered in
app.module.tsbefore deleting anything. -
Keep
test:kyc-guard-scanand extend it to coverRolesGuardthe same way.
Constraints
- Guard registration order is load-bearing.
app.module.ts:306-321registersStrategyAuthGuard→DistributedRateLimitGuard→RolesGuard→KycGuard. Preserve that order exactly; changing it changes authorisation behaviour. - Do not delete a duplicate that is genuinely used by a different module without checking. Use the compiler (
npx tsc --noEmit) as the safety net, then delete imports it flags. - Barrel files can introduce circular imports; keep them flat and import from specific files where a cycle would result.
Acceptance Criteria
- A current duplicate-filename scan is recorded in the issue, with each duplicate resolved or documented.
-
kyc.guard.tsandroles.decorator.tseach exist exactly once, and it is the registered one. -
src/common/is organised by concern with anindex.tsper subdirectory. - Guard registration order in
app.module.tsis unchanged. -
npm run test:kyc-guard-scan,npx tsc --noEmit, andnpm testall pass.
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 55
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SourceXXL/alian_structure-api
-
good first issue help wanted security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#266 ·
-
Parallelize the cache-warming loop in `cache-warming.service.ts` — warmers run strictly sequentiallyMay be free again @syntaxsuuvam-spec claimed this 16 days ago, and no pull request is open. Opengood first issue performance
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#240 ·
-
documentation help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
SourceXXL/alian_structure-api#215 ·
-
good first issue refactor tooling
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
SourceXXL/alian_structure-api#199 ·
-
help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SourceXXL/alian_structure-api#196 ·
All issues in SourceXXL/alian_structure-api
Similar issues
-
area: server priority: P3 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
appandflow/stim#4538 ·
Maintainers usually reply within 1 day
-
[BUG] Published Docker images lack the redis extra: HEADROOM_COMPRESS_SESSION_STORE stops startupPossibly taken @AlessandroSpallina claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
headroomlabs-ai/headroom#4513 ·
Maintainers usually reply within 1 day
-
bug extension extension: obsidian platform: Windows
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raycast/extensions#32838 · 1 comment ·
Maintainers usually reply within 1 day
-
copy design-review mac P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
tosunlab/hisarapp-core#510 ·
-
bug priority-medium to-agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day