Chapter 4
In this chapter, we will create a Query API that provides an overview of tasks. This will allow us to query and retrieve a list of active tasks from the system.
Fourth Usecase: Creating a Query API
-
Create the Query API Usecase:
- We will add a querying readmodel named
active task
. This readmodel will be used to fetch the data for our query.
- We will add a querying readmodel named
-
Configure the Query API:
- Set the Query Result to
Many
. This indicates that the query will return multiple records. - Name the Query
get all active tasks
. This name will be used to identify and access this query from the API.
- Set the Query Result to
Generate the Code
-
Set the Usecase Status:
- Ensure your usecase is set to Ready. This step is necessary for the code generator to recognize that the usecase is complete and ready for code generation.
-
Generate the Source Code:
- Verify that your local code generator is running. Generate the source code for the Query API to your machine.
Customize the Code
- No additional custom code is required for this Query API. The code generated will be sufficient for querying the
active task
readmodel as specified.
Test the Code
-
Run the Tests:
- Execute the tests to ensure that the Query API functions correctly and returns the expected results.
npm run test-integration
npm run test-unit
Deploy the Code
-
Configuration & Deployment:
- Setup your AWS Account and deploy your application to AWS.