Skip to content

test: add failing test for CI - #1

Merged
moriaren merged 14 commits into
mainfrom
feature/ci-fail
Apr 23, 2026
Merged

test: add failing test for CI#1
moriaren merged 14 commits into
mainfrom
feature/ci-fail

Conversation

@moriaren

Copy link
Copy Markdown
Owner

No description provided.

moriaren added 14 commits April 22, 2026 10:50
Update package.json migrate script to run `node-pg-migrate up` instead of invoking the binary without a subcommand. This ensures the npm script applies migrations (consistent with migrate:test) when executed.
Implement comment-like functionality across the stack: add a DB migration to create user_comment_likes with FK constraints and a uniqueness constraint; introduce UserCommentLikeRepository interface and Postgres implementation (add/verify/delete like). Add ToggleLikeCommentUseCase to toggle likes after verifying thread/comment existence. Expose a new HTTP endpoint (PUT /threads/:threadId/comments/:commentId/likes) with handler, route, and JWT auth middleware. Update ThreadRepositoryPostgres to fetch comments with aggregated like counts and return comments as part of the thread, and adjust GetThreadDetailUseCase to use thread.comments and include likeCount. Update DetailComment entity and its tests to require and validate likeCount. Also rename error middleware path to Interfaces/http/middlewares/errorMiddleware.js.
Move likes handlers/routes from src/Interfaces/http/api/comments/likes to src/Interfaces/http/api/likes, adjust middleware import paths accordingly, and register the likes router in createServer (mounted under /threads). This reorganizes the likes endpoint into a top-level API module and ensures it is wired into the server.
Register ToggleLikeCommentUseCase and UserCommentLikeRepository in createServer, and inject the use case into the likes route. Replace the old JWT-based auth middleware with a simpler authMiddleware that checks req.auth.credentials, update LikeCommentHandler to read user id from req.auth.credentials, and adapt likes routes to be mounted under /threads (relative path) and accept a handler instance. Also relocate error middleware to _middlewares. These changes wire the like-toggle feature and harmonize authentication routing/injection.
Instantiate LikeCommentHandler and pass the handler to the likes routes instead of forwarding the container. Adds an import for LikeCommentHandler and updates the default export to create the handler from the container and supply it to routes, ensuring the routes receive the proper handler instance.
Move express.Router() creation into the exported function so a fresh router instance is created per handler invocation instead of sharing a single router at module scope. This prevents cross-request/handler conflicts and allows handler-specific wiring.
Correct the import path for authMiddleware in src/Interfaces/http/api/likes/routes.js from '../../_middleware/authMiddleware.js' to '../../_middlewares/authMiddleware.js' to match the actual directory name and avoid module resolution errors. No functional changes made.
Import nanoid and set it as the default id generator for UserCommentLikeRepositoryPostgres (constructor defaults to nanoid). Removed the previous domain repository inheritance/import and updated createServer to pass nanoid when instantiating the repository so the id generator is explicit and available.
Safely destructure userId from req.auth using optional chaining and handle missing authentication: if userId is absent, respond with 401 and a JSON fail message ('Missing authentication'). This prevents runtime errors when auth credentials are not present before invoking ToggleLikeCommentUseCase.
@moriaren
moriaren merged commit 936d842 into main Apr 23, 2026
1 check passed
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