Skip to content
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

Ahnfikd7/create accept reject endpoint #57

Merged
merged 5 commits into from
Apr 7, 2024

Conversation

ahnfikd7
Copy link

ℹ️ Issue

Closes #22

📝 Description

Wrote a new function processDecision inside applications.service that updates the application stage of an applicant to the next stage or to rejected.
In the decision endpoint inside the applications.controller, it delegates the decision making to service i.e processDecision.

@ahnfikd7 ahnfikd7 self-assigned this Mar 12, 2024
Copy link
Member

@chromium-52 chromium-52 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Just a couple comments but looks good to me overall!

apps/backend/src/app.module.ts Outdated Show resolved Hide resolved
apps/backend/src/applications/applications.controller.ts Outdated Show resolved Hide resolved
apps/backend/src/applications/applications.controller.ts Outdated Show resolved Hide resolved
apps/backend/src/applications/applications.controller.ts Outdated Show resolved Hide resolved
}

//Check if the string decision matches with the Decision enum
const decisionEnum: Decision = Decision[decision as keyof typeof Decision];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓We definitely need to make sure that the decision we get is a valid Decision but I think line 46 in this file (where we type the decision parameter) tells Nest to check this for us and throw an error if the type doesn't match. Can you try commenting out this check and passing in an invalid value as the decision and see if the endpoint still responds with a 400 Bad Request error?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️A potentially better alternative altogether is to make an application decision dto whose fields are applicantId and decision. Then, you can add decorators from class-validator such as @IsEnum(Decision) to the fields to ensure that Nest performs type checks at runtime.

Copy link

@kimharr24 kimharr24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Just a few suggestions.

@ahnfikd7 ahnfikd7 merged commit f5fdd58 into main Apr 7, 2024
3 checks 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.

Create accept/reject applicant endpoint
3 participants