Skip to content

chore: add production environment config, resolve NestJS DI warnings, and prune legacy dependencies#638

Merged
TarunyaProgrammer merged 1 commit into
c2siorg:webiu-2026-gsocfrom
TarunyaProgrammer:chore/cleanups-and-fixes
Jun 6, 2026
Merged

chore: add production environment config, resolve NestJS DI warnings, and prune legacy dependencies#638
TarunyaProgrammer merged 1 commit into
c2siorg:webiu-2026-gsocfrom
TarunyaProgrammer:chore/cleanups-and-fixes

Conversation

@TarunyaProgrammer

Copy link
Copy Markdown
Collaborator

Overview

This PR implements critical cleanups, configuration fixes, and dependency pruning identified in the pre-development codebase audit. These changes optimize package sizes, standardize NestJS dependency injection patterns, consolidate duplicate API endpoints, and prepare the frontend for production build environments.

Closes #637


Problems Addressed & Decisions Made

1. Hardcoded Environment URLs

  • Problem: The Angular frontend only had a development environment configured (environment.ts), which hardcoded the API base URL to http://localhost:5050. This blocked production-ready static builds (e.g., for GitHub Pages deployment).
  • Decision: Created a new production configuration webiu-ui/src/environments/environment.prod.ts pointing to the production server. Modified angular.json to configure the fileReplacements utility under the production build block so that environment configurations are swapped dynamically at build time.

2. Implicit NestJS DI in UserModule & Test Suite Isolation

  • Problem: UserService injected GithubService, but UserModule did not explicitly import GithubModule. While NestJS resolved this globally in the application context, it caused compilation failures in standalone integration tests (specifically user.validation.spec.ts) because the dependencies of GithubModule (like CacheService and ConfigService) were missing.
  • Decision:
    • Added the explicit import of GithubModule in UserModule to guarantee correct dependency resolution.
    • Isolated user.validation.spec.ts by compiling only the UserController and providing a mock UserService. Since this test suite only verifies query/body validation pipes, isolating the controller bypasses compiling the entire module tree, removing dependency leakage and allowing tests to run instantly.

3. API Endpoint Duplication

  • Problem: Both the UserController and ContributorController exposed identical HTTP endpoints to fetch followers and following metrics from GithubService.
  • Decision: Consolidated all user social metrics under the UserController (/api/v1/user/followersAndFollowing/:username). Removed the redundant endpoint and service wrapper from the Contributor module to maintain a single source of truth.

4. Package Dependency Bloat & Duplication

  • Problem: webiu-ui had redundant dependencies: axios (unused, since the frontend uses Angular's native HttpClient), @types/jest (unused, since Jasmine/Karma is used), and husky (duplicated). The backend also had a duplicate husky declaration.
  • Decision: Pruned these dependencies from both package.json files and updated package-lock.json lockfiles. Pre-commit hooks are now correctly handled exclusively at the monorepo root level.

Verification & Build Log

  • Linter & Prettier: Verified with npm run lint and npm run format. All files pass cleanly with zero warnings or errors.
  • Backend Unit Tests: Verified with npm run test (103/103 Jest tests passing).
  • Frontend Unit Tests: Verified with ng test (36/36 Jasmine tests passing in ChromeHeadless).
  • Builds: Compiles successfully on both webiu-ui and webiu-server.

@TarunyaProgrammer TarunyaProgrammer merged commit ebb0fd0 into c2siorg:webiu-2026-gsoc Jun 6, 2026
2 checks passed
@TarunyaProgrammer TarunyaProgrammer added the GSOC-2026 webiu-2.0 label Jun 6, 2026
@TarunyaProgrammer TarunyaProgrammer self-assigned this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSOC-2026 webiu-2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant