Skip to content

Conversation

@UlisesGascon
Copy link
Member

@UlisesGascon UlisesGascon commented May 2, 2025

Related #219

Summary by CodeRabbit

  • New Features

    • Introduced website routes for viewing the index and individual project pages, with robust error handling and "Not Found" support.
    • Added modular EJS templates with reusable head, navigation, and footer partials for consistent page layout.
    • Implemented dynamic internal link generation for both static reports and server mode.
    • Added schema validation for index and project data to ensure data integrity.
  • Bug Fixes

    • Improved and hardened server shutdown logic, including forced termination and active connection cleanup.
  • Refactor

    • Modularized data collection and validation for reports.
    • Updated template structure for better maintainability and layout.
    • Reorganized static asset serving and Express app configuration.
  • Tests

    • Added comprehensive integration and unit tests for website routes and internal link generation.
    • Corrected test import paths and enhanced test suite descriptions.
  • Chores

    • Updated import paths and improved logging for clarity and maintainability.
    • Added generic data fetching method and project retrieval in data store.
    • Removed unused dependency "serve-index".

@UlisesGascon UlisesGascon added this to the v1.0.0 milestone May 2, 2025
@UlisesGascon UlisesGascon self-assigned this May 2, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 2, 2025

Walkthrough

This update introduces several new features and refactors across the server, reporting, and testing layers. The HTTP server now supports website routes with EJS templating and improved shutdown logic, including forced connection termination and timeouts. The reports module is modularized with new data collection and validation functions, internal link generation, and enhanced template handling using EJS partials for head, navigation, and footer. JSON schemas for index and project data are added, along with corresponding validators. The store layer gains a method for fetching projects by ID. Comprehensive tests are added for website routes and internal link generation.

Changes

File(s) Change Summary
__tests__/httpServer/apiV1.test.js Corrected import paths, updated Jest mock path, and renamed test suite description to specify API version.
__tests__/httpServer/website.test.js Added integration tests for website routes, covering root and project detail endpoints with various scenarios.
__tests__/reports.test.js Added unit tests for internalLinkBuilder covering static and server modes.
__tests__/schemas.test.js Extended schema validation tests for validateProjectData and validateIndexData using sample fixtures.
__fixtures__/index.js Added sample data objects sampleProjectData and sampleIndexData for schema validation tests.
server.js Enhanced shutdown logic: checks server existence, adds hard timeout, and improves error handling and log flushing.
src/httpServer/index.js Refactored route imports, added web router, changed static asset handling, configured EJS templates, tracked TCP connections, and improved shutdown sequence.
src/httpServer/routers/apiV1.js Updated import paths for generateStaticReports and logger.
src/httpServer/routers/website.js New Express router for website routes (/, /projects/:id) with data collection, validation, and error handling.
src/reports/index.js Added collectIndexData, collectProjectData, and internalLinkBuilder. Refactored report generation, modularized data collection, updated template handling, and output structure.
src/reports/templates/index.ejs, src/reports/templates/project.ejs Refactored to use partials for head, navigation, and footer; improved layout and link generation.
src/reports/templates/notFound.ejs New template for "Not Found" error page.
src/reports/templates/partials/head.ejs, partials/navigation.ejs, partials/footer.ejs Added new EJS partials for head, navigation bar, and footer.
src/schemas/index.js Added and exported validateProjectData and validateIndexData using new schemas; enabled union types in Ajv.
src/schemas/indexData.json, src/schemas/projectData.json Added new JSON schemas for index and project data structures.
src/store/index.js Added generic getFn for fetching records by ID and exposed getProjectById in the store object.
package.json Removed serve-index dependency version 1.9.1.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HTTPServer
    participant WebRouter
    participant Store
    participant Reports
    participant Templates

    User->>HTTPServer: GET /
    HTTPServer->>WebRouter: Handle /
    WebRouter->>Reports: collectIndexData(knex)
    Reports->>Store: Fetch projects, checklists, checks
    Store-->>Reports: Data
    Reports-->>WebRouter: Validated index data
    WebRouter->>Templates: Render index.ejs with data
    Templates-->>User: HTML response

    User->>HTTPServer: GET /projects/:id
    HTTPServer->>WebRouter: Handle /projects/:id
    WebRouter->>Store: getProjectById(id)
    Store-->>WebRouter: Project or null
    alt Project found
        WebRouter->>Reports: collectProjectData(knex, id)
        Reports->>Store: Fetch project-related data
        Store-->>Reports: Data
        Reports-->>WebRouter: Validated project data
        WebRouter->>Templates: Render project.ejs with data
        Templates-->>User: HTML response
    else Project not found or invalid id
        WebRouter->>Templates: Render notFound.ejs
        Templates-->>User: 404 HTML response
    end
Loading

Possibly related PRs

Poem

🐇
Hopping through the code so bright,
New routes and templates come to light.
With schemas neat and data true,
The links now know just what to do.
The server shuts with gentle might,
And tests ensure all works just right.
VisionBoard leaps ahead tonight!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@UlisesGascon UlisesGascon requested a review from Copilot May 2, 2025 15:13

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

- Use integrity check for FE libraries
- Remove unused static resources from server
- Remove dependency `serve-index`
- Add test cases for `validateProjectData` and `validateIndexData` schemas
- Proper ordering of shutdown steps
- More graceful handling of active connections
- Better error handling and logging
- Move to `__dirname` from `process.cwd()`
- Fix bug filtering scorecard ownership
- Enhance navigation accessibility
@UlisesGascon
Copy link
Member Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented May 2, 2025

✅ Actions performed

Full review triggered.

coderabbitai[bot]

This comment was marked as off-topic.

@UlisesGascon
Copy link
Member Author

I will handle the last suggestions in my next PR

@UlisesGascon UlisesGascon mentioned this pull request May 2, 2025
7 tasks
@UlisesGascon UlisesGascon merged commit 5f02b88 into main May 2, 2025
6 checks passed
@UlisesGascon UlisesGascon deleted the ulises/2019-migration branch May 2, 2025 17:49
UlisesGascon added a commit that referenced this pull request May 3, 2025
Ref: #228 (comment)

- Replace `process.cwd()` with `__dirname` for reliable path resolution
- Fix HTTP server connection listener leak on multiple start/stop cycles
- Add default empty string for ref parameter in internalLinkBuilder
- Replace `parseInt()` with `Number()` for better type conversion
- Add `implementation_status` enum to `indexData` schema
UlisesGascon added a commit that referenced this pull request May 3, 2025
Ref: #228 (comment)

- Replace `process.cwd()` with `__dirname` for reliable path resolution
- Fix HTTP server connection listener leak on multiple start/stop cycles
- Add default empty string for ref parameter in internalLinkBuilder
- Replace `parseInt()` with `Number()` for better type conversion
- Add `implementation_status` enum to `indexData` schema
UlisesGascon added a commit that referenced this pull request May 3, 2025
Ref: #228 (comment)

- Replace `process.cwd()` with `__dirname` for reliable path resolution
- Fix HTTP server connection listener leak on multiple start/stop cycles
- Add default empty string for ref parameter in internalLinkBuilder
- Replace `parseInt()` with `Number()` for better type conversion
- Add `implementation_status` enum to `indexData` schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants