-
Notifications
You must be signed in to change notification settings - Fork 0
wrote the module for job_postings and created tests #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive job postings module with full CRUD operations, search functionality, and extensive test coverage. The implementation follows established patterns from other modules and includes proper validation, error handling, and integration with professional profiles.
- Module for job postings with schema-based model, service layer, and REST API endpoints
- Complete test suite including unit tests for service/controller and integration tests for API routes
- Professional profile integration allowing companies to manage their job postings
Reviewed Changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/modules/job-postings/job-posting.model.ts | Defines JobPosting schema with enums, nested schemas, and model class |
| server/src/modules/job-postings/job-posting.service.ts | Business logic layer with CRUD operations and search functionality |
| server/src/modules/job-postings/job-posting.controller.ts | HTTP request handlers for all job posting endpoints |
| server/src/modules/job-postings/job-posting.router.ts | Route definitions with validation middleware |
| server/src/modules/job-postings/utils/job-posting.validator.ts | Class-validator schemas for request validation |
| server/src/modules/job-postings/utils/job-posting.errors.ts | Custom error classes for job posting operations |
| server/src/modules/professional-profiles/professional-profile.router.ts | Adds nested job posting routes under company profiles |
| server/src/server.ts | Registers job posting router in main application |
| server/tests/* | Comprehensive test files for unit and integration testing |
| server/test-job-postings.sh | Test script for running job posting module tests |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| @IsNotEmpty() | ||
| jobTitle!: string; | ||
|
|
||
| // Can be either a string (ObjectId) or populated company object |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The companyRef field lacks validation decorators. It should include @IsMongoId() for when it's a string or @ValidateNested() with @type() when it's an object, similar to other validator classes in the codebase.
| // Can be either a string (ObjectId) or populated company object | |
| // Can be either a string (ObjectId) or populated company object | |
| @IsMongoId() | |
| @ValidateNested() | |
| @Type(() => TestCompanyRefValidator) |
| // Transform the route parameter to match the controller expectation | ||
| req.params.companyId = req.params.id; | ||
| // The decorator wraps the method to accept 3 parameters, so we cast it | ||
| (jobPostingController.getJobPostingsByCompany as any)(req, res, next); |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type casting with 'as any' bypasses type safety. Consider creating a wrapper function or adjusting the controller method signature to properly handle the middleware pattern instead of forcing type coercion.
| (req: Request, res: Response, next: NextFunction) => { | ||
| // The decorator wraps the method to accept 3 parameters, so we cast it | ||
| (jobPostingController.createJobPosting as any)(req, res, next); | ||
| } |
Copilot
AI
Sep 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type casting with 'as any' bypasses type safety. Consider creating a wrapper function or adjusting the controller method signature to properly handle the middleware pattern instead of forcing type coercion.
| (req: Request, res: Response, next: NextFunction) => { | |
| // The decorator wraps the method to accept 3 parameters, so we cast it | |
| (jobPostingController.createJobPosting as any)(req, res, next); | |
| } | |
| function handleCreateJobPosting(req: Request, res: Response, next: NextFunction) { | |
| jobPostingController.createJobPosting(req, res, next); | |
| } | |
| handleCreateJobPosting |
naasanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a couple other changes that needed to be made. Might need to update tests as well
| jobPostingRouter.get( | ||
| "/company/:companyId", | ||
| validation(validateId("companyId")), | ||
| jobPostingController.getJobPostingsByCompany | ||
| ); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated between here and professional-profile.router. Should be removed from here
| // POST /api/professional-profiles/:id/job-postings - Create job posting for a specific company | ||
| professionalProfileRouter.post( | ||
| "/:id/job-postings", | ||
| validation(validateId()), | ||
| // Custom middleware to set companyRef before validation | ||
| (req: Request, res: Response, next: NextFunction) => { | ||
| req.body.companyRef = req.params.id; | ||
| next(); | ||
| }, | ||
| validation(validateBody(JobPostingValidator)), | ||
| (req: Request, res: Response, next: NextFunction) => { | ||
| // The decorator wraps the method to accept 3 parameters, so we cast it | ||
| (jobPostingController.createJobPosting as any)(req, res, next); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is duplicated between here and job-posting.router. Should be removed from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be editing things in core. This is probably also causing the "casting to any" comment that copilot made. this change should be reverted
Module for job_postings using the schema in the drive.
Created tests using chat, so not 100% if comprehensive so please check to make sure.