Files and names
CAITS finds the parts of your app by where their files are and what they are called: you register nothing. This page lists each kind of file, where it goes, and its test. If a handler never runs, or a view finds no frontend, start here.
In a context
The paths start from the folder of a context, such as src/backend/messages/.
| What | File | Its test |
|---|---|---|
| The bindings | di.ts: a list of bind(…). CAITS finds the context by this file. | The integration tests |
| The bindings of the tests | test.di.ts: they replace those of di.ts in the tests | — |
| The shortcut | package.json: #context/ leads to the files of the context | — |
| A use case | command/ if it changes something, query/ if it only reads | — |
| A DTO | <use-case>.dto.ts: the input DTO and, in the backend, the output DTO, as plain classes | — |
| A handler | <use-case>.handler.ts: one class whose execute takes the input DTO and, in the backend, returns its output DTOs, each typed with its class | <use-case>.application.test.ts |
| A controller | <use-case>.http.controller.ts, in the backend: it extends Controller<InputDto, OutputDto> | <use-case>.http.presentation.test.ts |
| An entity, a value object | domain/, domain/ | Through the use cases; <Entity>.test.ts if needed |
| A domain error | domain/: a class …Error that extends Error | Through the use cases |
| A domain event | domain/, in the backend: it extends DomainEvent | Through the use cases |
| A port | domain/: the interface and its token, under one name | — |
| A contract | domain/: the tests of every adapter | — |
| An adapter | infra/: it implements the interface that it imports from domain/ | <adapter>-<port>.test.ts, which runs the contract |
| A context map | context-map.ts: what the context shares, and what it hears | context-map.test.ts |
In a frontend context
A frontend context has the files above, except the controllers and the domain events, and these:
| What | File | Its test |
|---|---|---|
| An event | event/, with readonly type = "<context>.<event>" as const | — |
| The events of the context | event/: their union | — |
| The store | presentation/: { initialState, reduce, send } | Through the tests of the views |
| The type of its frontend | presentation/: its entry in Frontends, named after the folder | — |
| A view | presentation/, with its stylesheet, its presenter and its loader | <View>.test.ts |
| A component | presentation/ | Its own test, next to it |
The test helpers
Each module also exports Vitest's functions (describe, expect, vi…), so a test imports everything from one place.
| Import from | For | It gives |
|---|---|---|
@ingenioz-it/ | a backend use case | test with app, applicationScenario |
@ingenioz-it/ | a controller | test with app, presentationScenario |
@ingenioz-it/ | a backend adapter | useTempDirectories |
@ingenioz-it/ | a backend context map | ContextMap, backendTest |
@ingenioz-it/ | the integration tests | productionBackend |
@ingenioz-it/ | a frontend use case | test with app, applicationScenario |
@ingenioz-it/ | a view or a component | testPresentation, globalWith, mountTemplate, settle, press |
@ingenioz-it/ | a frontend adapter | Vitest's functions |
@ingenioz-it/ | a frontend context map | eventsFor |
The shortcuts of the imports
No import goes up a folder (../), not even in a test: an import keeps working when its file moves.
| Shortcut | Where | It leads to |
|---|---|---|
#context/ | In a context | The files of the same context |
#shared/ | In a backend context | src/ |
#frontend-shared/ | In a frontend context | src/ |
#backend/, #frontend/ | In the routes | src/, src/ |
@ingenioz-it/ | Everywhere | CAITS itself, by its package name |