Welcome to the paired programming exercise! In this task, you will be building a RESTful API to manage person data. The API should support basic CRUD operations, authentication, and include unit tests.
Define the schema for person data with the following fields:
- First Name
- Last Name
- Date of Birth
- Email Address
Create an authentication route that allows users to log in. You will need to:
- Implement a login route that issues a JWT token.
- Implement middleware to protect the other routes, requiring a valid JWT token.
Implement the following routes:
- POST
/persons
: Create a new person. - GET
/persons
: Retrieve a list of all persons. - GET
/persons/:id
: Retrieve a specific person by ID. - PUT
/persons/:id
: Update a specific person by ID. - DELETE
/persons/:id
: Delete a specific person by ID.
All routes except login should require authentication.
Write unit tests to cover both success and failure scenarios for the above routes. Use Jest or another testing framework of your choice.
Please include meaningful inline comments in your code to explain the logic and any decisions made.
-
Open your terminal and navigate to the directory where you want to clone the repository.
-
Run the following command:
git clone https://github.com/hcevikGA/ga-ppt.git
-
Navigate to the project directory:
cd ga-ppt
- Install dependencies
npm install
- Start the server
npm start
- Run tests
npm test
- Code quality and style
- Proper implementation of REST principles
- Proper handling of authentication
- Coverage and quality of unit tests
- Thoughtful inline comments and documentation
You have 1 hour and 30 minutes for this task. If you have any questions or need further clarification on any part of the task, please don't hesitate to ask.
Good luck!