Project developed in response to a talent adquisition test with the following requeriments:
You have to prepare a solution to the proposed problem in the defined period of time. The solution must comply with the requirements. For anything not explicitly listed, you are free to choose whatever technology/library/tool you feel comfortable with.
Once ready, you must send a package with the source code of the solution, so it can be built and reviewed by Musala Soft. Instructions how to use the solution must also be provided (resource names, SQL scripts to import test data, other scripts, etc.). If you have completed the task after the deadline has expired, you are still encouraged to submit a solution.
- Programming language: JavaScript
- Framework: Node.js/JavaScript + Angular/React or other
- Database: MongoDB or in-memory
- Automated build: Solution of choice
This sample project is managing gateways - master devices that control multiple peripheral devices. Your task is to create a REST service (JSON/HTTP) for storing information about these gateways and their associated devices. This information must be stored in the database.
When storing a gateway, any field marked as “to be validated” must be validated and an error returned if it is invalid. Also, no more that 10 peripheral devices are allowed for a gateway.
The service must also offer an operation for displaying information about all stored gateways (and their devices) and an operation for displaying details for a single gateway. Finally, it must be possible to add and remove a device from a gateway.
- a unique serial number (string),
- human-readable name (string),
- IPv4 address (to be validated),
- multiple associated peripheral devices.
- a UID (number),
- vendor (string),
- date created,
- status - online/offline.
Please, provide
- Basic UI - recommended or (providing test data for Postman (or other rest client) if you do not have enough time.
- Meaningful Unit tests.
- Readme file with installation guides.
- An automated build.
The project contains an Api backend project and a Client frontend project which can be globally treated as a single project from current directory due to the use of shelljs
A working MongoDB database URL is REQUIRED by the project to work. It is required to be defined as an environment variable
The project supports the following environment variables:
- DATABASE_URL (required): It's the URL to the mongoDB database to be used by the project
- STATIC_CONTENT_PATH: It's the path to a static distribution folder to be served as SPA (fallback to index.html). The default value is
../client/dist
, which is the distribution folder of the client - PORT: Defines the port where application should be listening. (Default is 3001);
- HOST: Defines the host where application should be listening
The environment variables can be set globally or as defined in the Environment section of the API documentation.
npm install
npm run dev
npm start
Api unit testing with jest
npm run test-api
End to end testing with Cypress
npm test
The most basic usage will be running
npm install
npm start
This will install the api and client project if node_modules folder is missing in at least one of them. Then if tere's no "./dist" folder inside client project, the client project will be built. Then the API project is started (it should connect to database and serve the static content if environment is configured properly, see Environment section )
After the app is installed, it can be re-installed (both api and client) by running
npm run install
After the client is built, it can be re-built by running
npm run build-client
-
Propose a distribution strategy. Some way to isolate the client's distribution folder along with a compact (maybe uglified) version of the api/server
-
Add some presentation and styling for Home and NotFound pages or remove them. It's pending since it's considered to be way far from the main objective of the exercise
-
Validate gateway endpoint so it doesn't allow editing the device's property if there are duplicated device _id's
-
Implement lazy load for the page to load faster
-
Validation timeout reset Timeout is not being reset properly
-
Separate selector component Create 2 components, one for displaying the device information and the other for add the device.