Skip to content

Refactor application structure and enhance logging and testing#63

Open
adeyinkaoresanya wants to merge 45 commits into
v2-typescriptfrom
adeyinka-changes-v2-ts
Open

Refactor application structure and enhance logging and testing#63
adeyinkaoresanya wants to merge 45 commits into
v2-typescriptfrom
adeyinka-changes-v2-ts

Conversation

@adeyinkaoresanya
Copy link
Copy Markdown
Collaborator

Pull Request Template

This pull request introduces several improvements and refactors across the codebase, focusing on environment configuration, authentication flow, middleware and error handling, and developer tooling. The most significant changes are the refactoring of the authentication controller for better clarity and error handling, the addition of new environment variables for event badging and database configuration, and the introduction of a custom Jest configuration with proper environment setup for testing.

Key changes include:

Authentication Flow and Error Handling

  • Refactored AuthController to improve clarity, error handling, and maintainability:
    • Consolidated and streamlined login and callback endpoints for GitHub and GitLab.
    • Introduced consistent use of a custom AppError class for error responses.
    • Removed redundant or legacy endpoint logic and moved development form rendering to a shared utility.
    • Improved response handling for both production and development environments. [1] [2]

Environment and Configuration

  • Expanded .env.example with new variables for event badging OAuth, GitHub App installation, test database configuration, and webhook paths to support additional deployment and testing scenarios. [1] [2]

Middleware and Application Structure

  • Updated src/app.ts to:
    • Add SystemController for system-level endpoints.
    • Integrate custom requestLogger and globalErrorHandler middleware.
    • Remove legacy health and root endpoints in favor of controller-based routing.
    • Ensure only controller-based endpoints are exposed and all errors are handled through middleware.

Testing and Developer Tooling

  • Added a custom Jest configuration (jest.config.ts) and setup file (jest.setup.ts) to load environment variables and support TypeScript testing.
  • Updated package.json to use the new Jest setup, run tests in-band, and add/upgrade related dependencies (e.g., ts-jest, supertest, winston). [1] [2] [3] [4] [5]

Miscellaneous

  • Removed .vscode/settings.json containing hardcoded database credentials for improved security and portability.
  • Minor update to .husky/pre-commit script output for consistency.

These changes collectively improve the maintainability, security, and testability of the project.

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…elopment

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…t is parsed as number in database setup

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ring service to use it for badge calculation

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ller methods

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ents

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
… baseUrl

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…okit

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ng purposes

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…gingController

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ors correctly

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ody correctly

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…handling and code clarity

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
… logging capabilities

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…processing

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…d logging

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
… services and configuration

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…etter error tracking

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…ck.json

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…egration tests

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
…st isolation

Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Signed-off-by: AdeyinkaOresanya <adeyinkaoresanya@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant