Skip to content

Conversation

@VidurShah
Copy link
Collaborator

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.

Copy link
Contributor

Copilot AI left a 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
Copy link

Copilot AI Sep 18, 2025

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.

Suggested change
// Can be either a string (ObjectId) or populated company object
// Can be either a string (ObjectId) or populated company object
@IsMongoId()
@ValidateNested()
@Type(() => TestCompanyRefValidator)

Copilot uses AI. Check for mistakes.
// 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);
Copy link

Copilot AI Sep 18, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +76
(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);
}
Copy link

Copilot AI Sep 18, 2025

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.

Suggested change
(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

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@naasanov naasanov left a 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

Comment on lines +26 to +31
jobPostingRouter.get(
"/company/:companyId",
validation(validateId("companyId")),
jobPostingController.getJobPostingsByCompany
);

Copy link
Collaborator

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

Comment on lines +63 to +76
// 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);
}
Copy link
Collaborator

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

Copy link
Collaborator

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

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.

3 participants