An application allowing users to explore, create, annotate, and share extensions of the MITRE ATT&CK® knowledge base. This repository contains the REST API service for storing, querying, and editing ATT&CK objects.
Separate the database logic from the service layer to improve code modularity, maintainability, and facilitate testing.
Background:
Currently, our Express.js API directly performs database operations in the service layer. This intertwined structure can become a maintenance challenge and hinders the clarity and separability of concerns in our codebase.
Proposed Changes:
For each of the service layer modules, the following should be completed:
Introduce a Repository Layer
Create a new layer (Repository or DAO) specifically for handling raw database operations.
Define methods in the repository layer like findWithAggregation, findMatrixById, and findOneMatrixById.
Refactor Service Layer
The service layer should call the newly defined repository methods for database operations.
Retain business logic, such as handling transactions and complex computations, in the service layer.
Unit Testing
Adjust unit tests (if any) to align with the new structure.
Mock the repository methods when testing the service layer.
Update Controllers
Ensure controllers remain thin and only handle HTTP requests, input validation, and returning responses.
Overhaul Error Handling
Implement and use custom exception classes hosted by the app/exceptions module.
Tasks
All tasks should branch off of the branch linked to #281.
The parent branch (i.e., the branch linked to #281) will merge into develop when all tasks are completed.
Use matrices-service.js + matrices-repository.js as reference examples for refactoring.
Objective:
Separate the database logic from the service layer to improve code modularity, maintainability, and facilitate testing.
Background:
Currently, our Express.js API directly performs database operations in the service layer. This intertwined structure can become a maintenance challenge and hinders the clarity and separability of concerns in our codebase.
Proposed Changes:
For each of the service layer modules, the following should be completed:
Introduce a Repository Layer
Refactor Service Layer
Unit Testing
Update Controllers
Overhaul Error Handling
app/exceptions
module.Tasks
All tasks should branch off of the branch linked to #281.
The parent branch (i.e., the branch linked to #281) will merge into
develop
when all tasks are completed.Use
matrices-service.js
+matrices-repository.js
as reference examples for refactoring.[X] Refactor matrices-service
[x] #307
[x] #306
[ ] #305
[ ] #304
[ ] #303
[x] #302
[x] #301
[x] #300
[x] #299
[x] #298
[x] #297
[x] #296
[ ] #295
[x] #294
[x] #293
[ ] #292
[x] #291
[x] #290
[x] #289
[x] #288
[x] #287