The aim of this challenge is to implement the requirements laid out below and to improve on the existing codebase. You may not import any other libraries other than the ones provided already in package.json
. You have one week to finish this challenge upon receipt.
Upload your work in a public git repository with a name randomly generated from this website: https://www.imprima.com/resources/project-name-generator
- Node v10 LTS
$ npm install
To run the app:
$ npm run start
To test the code:
$ npm run test
The app has a single endpoint, /shape
, that takes in two objects in its payload. The endpoint checks if these two shapes will collide in a Cartesian plane and provides either a true
or a false
in one of the response's fields.
Complete the challenge by doing the following:
- Finish the
/healthCheck
endpoint by returning your entire name as a string in the json response - Implement the unfinished
collides(other: Shape)
in theRect
class - Create a new
Line
Shape class that implementsShape
. Let it be usable as input in the endpoint for checking collisions (i.e. you should be able to check if aLine
collides with another shape, including otherLine
s). Hint:Shape
has a membercenter
. For the purpose of this implementation, assume thatcenter
is one of theLine
's two end points. - Add the necessary logging in various stages of the code
- Ensure that the currently implemented unit tests are all successful, and add new unit tests for edge cases and the newly added
Line
class - Refactor the code to avoid duplication in
Rect
andCircle
and the newly createdLine
. You may use any design patterns you want - Clean the code as you see fit
Send an email to [email protected] and CC [email protected] with the link to your git repository.