The application has five layers separated by directories. They are core, adapter, api, cron and helper.
The main idea behind the layers is to provide the separation of concerns.
It's dependencies rules are described on each respective section bellow and applied on .eslintrc.yml.
This layer contains the core logic, composed of models, services abstractions, and use cases.
This layer has no dependency on any other layer. It is a self-contained package. No external library can be imported on it.
This layer holds the implementation of the services specified on the domain layer.
It depends on core
and helper
layers and can import external libraries.
Adapters are implementations of core services and should be as thin as possible, containing instructions strictly necessary to perform the the external service adaptation. Codes exclusivelly related to the external service, must be kept in an external library or in the helper
layer.
The API layer is composed of an abstraction of the endpoints and their implementations.
It provides external access to the core logic.
The endpoint classes should delegate all business rules to the UseCases objects.
It's scope should be limited to:
- Validate and consume the HTTP parameters
- Construct and execute the use cases
- Build a success or error response
The cron layer is composed of an abstraction of the cron tasks and their implementations.
Every code that is not directly related to the domain has to be in this layer.
It's composed of a set of self-contained packages that are candidates to became an external module that can be reused in any other applications.
This project requires the npm installed to build, test, and run.
Port number which the server must to listen for incoming requests. Default: 3000
Port number which the server must to listen for incoming requests. Default: /api
Before run any command below, install the modules dependencies:
npm install
To run the EsLint validation, run the following npm script:
npm run lint
To run the EsLint fix, run the following npm script:
npm run lint:fix
To run the tests of the internal packages, run the following npm script:
npm run test
External tests are test that depends of external services to run successfuly. They can be identified by the .external.test.ts
extension.
To run the tests, run the following npm script:
npm run test:external
To run all Jest tests, run the following npm script:
npm run test:all
To run the application, use one of the following methods:
npm start
or
node .