Congratulations! Not by hearsay, you already know about the Backend structure, NodeJS and how to write clean, readable and high-quality code. But there is one "but"... Not all projects that will come on your way will be written by developers who also know about this as much as you are
Refactor the project, keeping all it's functionality (oh yeah, this is working)
- The project has only the backend part
- Whole project functionality is working and even covered by the tests. How to run the server and tests you will know by reading the README.md
- Unfortunately, there is no documentation or the "requirements" regarding the business logic... However - you have the source code, so as they say:
"The code is the documentation"
- Beside of invoking the tests, to figure out the existing business logic - the Postman collection is here to help. Please feel free importing it (don't forget the postman env file) into your own Postman to see the requests examples and playing with those requests during manual testing.
Technologies:
- Split the code by layers (business logic layer, data access layer , etc.)
- Create file structure
- Get rid of code duplicates
- Eliminate anti-patterns usage
- Fix inefficient implementation (redundant calls to DB, unnecessary loops, etc.)
Warning:
index.js
file must export an Express server instance- do not edit files in
tests
folder, the original ones will be used after all
Optional tasks:
- Add logger (of your choice). On each
request
you need to log:- incoming request: URL, method, date of invocation
- server response: URL, method, total time of processing the request, response HTTP code
- During server start-up:
- validate the environment variables. In case if something is missing - log error and terminate the node process.
- validate the database connection. In case if the server couldn't connect to the DB - log error and terminate the node process
- Implement graceful shutdown
- Configure the pre-commit hook to run eslint
- Persist the project functionality.
- Code quality (clean, readable)
Extra 1 point can be earned for completing all "optional tasks"
Happy refactoring!