Skip to content

Ayuklarissa/CodevigorTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodevigorTest

CodevigorTest

Question 2.1: Explain your decisions

Structure my code the way I did

  • I chose to structure my code in this way because it's easy to read and modify if necessary.
  • I equally follow good practices found on the node js community.

Production Environment Best Practices

In a production environment, several major adjustments and enhancements would be performed to ensure the security, stability, and scalability of the application. Here's what would be done differently:

Enhancements to Security

  • Robust user authentication and authorization systems would be developed.
  • Content Security Policy (CSP) and CORS policies would be used.
  • Input validation and cleanliness would be strictly enforced to prevent security flaws.

Monitoring and Logging

  • Extensive logging would be put in place to monitor application behavior and identify errors.
  • Real-time application and server monitoring technologies would be used to spot anomalies and performance bottlenecks.

Error Handling and Reporting

  • Detailed error handling would be implemented, including appropriate status codes and specific error messages.
  • Error tracking and reporting technologies would be used to monitor and address mistakes as soon as they occurred.

Authentication and Authorization

  • More complex authentication and authorization techniques, such as OAuth 2.0 or OpenID Connect, may be used for better security and integration capabilities.
  • Token expiration and renewal procedures would be implemented to improve security.

Documentation

  • Comprehensive API documentation would be generated and maintained for both developers and API consumers using technologies such as Swagger.

Testing

  • Unit testing, integration testing, and end-to-end testing, would be performed to assure functionality and security.
  • Tools such as Mocha, Chai, and Supertest would be utilized for automated testing.

Backup and Recovery

  • Regular database backups and a disaster recovery plan would be constructed to assure data integrity and availability in the event of an unforeseen occurrence.

Question 2.2: Code Review

Issues:

  1. Lack of Validation: The code does not do adequate input validation that can cause problems if the request body is incorrect or lacking needed fields.

  2. Error Handling: The code does not properly handle errors because even if 'db.addUser(user)' fails, the server answer will still be "User added." Proper error handling should be used.

Potential Enhancements:

  1. Input Validation: Include input validation to check that the request body has the appropriate fields and that the data is formatted correctly. For this purpose I would use express-validator.

  2. Apply Constants: To improve code readability and maintainability, replace the number '21' with a named constant. For example, starting using 'const minimumAge = 21'.

Part 3: Time Management Task

Task 1: Fix a Critical Bug in the Login Module

Priority: High Timeline: Day 1-2

Okay, so fixing a critical bug sounds important. People need to log in to use the app, right? I'll start by identifying and understanding the bug. Maybe it's causing people not to log in, which is bad. Once I know what's wrong, I'll work on fixing it. It might take a day or two because bugs can be tricky.

Task 2: Develop a New Feature Highly Requested by Clients

Priority: Medium Timeline: Day 3-4

Clients have been asking for this new feature for a while, so it's kind of important too. I'll spend some time planning out what the feature should do and how it should look. Then, I'll start coding it. It might take a couple of days because I want to make sure it works well.

Task 3: Document the API Developed in Task 1

Priority: Medium Timeline: Day 5

Documenting things is not my favorite, but it's important so that others can understand how the API works. I'll set aside a day to write down what each API endpoint does, what data it needs, and what it gives back. I'll use swagger to make it look nice.

Task 4: Optimize Database Queries in an Existing Module

Priority: Low Timeline: Day 6-7

Optimizing the database sounds like it could make things faster, but it's not as urgent as the bug and the new feature. I'll take a look at the existing code and see if there are any slow database queries. Then, I'll try to make them faster. This might take a couple of days because I need to be careful not to break anything while making it faster.

Overall

So, in one week, here's what I'm thinking:

  • Days 1-2: Fix the critical bug in the login module.
  • Days 3-4: Work on the new feature requested by clients.
  • Day 5: Document the API I developed in Task 1.
  • Days 6-7: Optimize database queries in an existing module.

About

CodevigorTest

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors