Feat/add POST api endpoint for skill relation#501
Conversation
…lated skills with corresponding schemas and validation logic.
…e schema and added new service layer for skills hierarchy and skill to skill
da5611d to
88dd1f2
Compare
…T endpoints in skill module
| @@ -0,0 +1,246 @@ | |||
| import { SkillToSkillRelationService } from "./skillToSkillRelation.service"; | |||
There was a problem hiding this comment.
These tests do not follow the convention we have refer to the testing guidelines documentation
The tests are expected to follow the Gherkin conventions when commenting in our tests.
| modelId: string, | ||
| requiringSkillId: string, | ||
| requiredSkillId: string, | ||
| relationType: string |
There was a problem hiding this comment.
Instead of the string, use enum SkillToSkillRelationType
There was a problem hiding this comment.
ohhh... my bad i though i fixed it as well i will check it
| relationType: string | ||
| ): Promise<ISkill & { relationType: SkillToSkillRelationType }> { | ||
| // 1. Validate relationType | ||
| if (relationType !== SkillToSkillRelationType.ESSENTIAL && relationType !== SkillToSkillRelationType.OPTIONAL) { |
There was a problem hiding this comment.
This is already tested via the handler.
We don't want to test it again (kind of waste of resources 😂, a joke).
It is a double work
| } | ||
|
|
||
| // 2. Fetch the requiring skill | ||
| const requiringSkill = await this.skillRepository.findById(requiringSkillId); |
There was a problem hiding this comment.
This can fail, it should be trapped in a try-catch, so that the service is able to throw service errors
| const createdRelations = await this.skillToSkillRelationRepository.createMany(modelId, [newRelationSpec]); | ||
|
|
||
| if (createdRelations.length === 0) { | ||
| throw new SkillToSkillRelationValidationError( |
There was a problem hiding this comment.
This is not true.
If the createdRelations.length == 0, it does not mean that the code was incosistent only.
It can also mean that there were mongoose model construction errors.
Check the repository for more information.
Ideally the CODE INCOSISTENT is a business rule, it should belong to the service
…pdate skill relation services and tests
…o-skill relation handlers
This pull request contains new POST api endpoint for skill relations