This project is currently a proof of concept for web strategy game server.
cd containers
docker-compose up -d
npm run build
npm run build:watch
npm run start
Once launched, the app is listening on port 3000
and accept HTTP requests for commands and queries.
You can find every possible endpoints in the router.ts
file.
Contains implementation of the app required ports. It includes database connection and queries, logger and lock mechanism.
MongoDB implementation for repository port methods. Simple adapter to call mongoDB, and define collections.
Every model is built on the same pattern:
document
: declare document classes and export Typegoose modelrepository
: extends the generic repository and implement specific methods
Contains all the app features, divided into commands and queries.
It is designed to follow a fetch -> exec -> save
pattern to prevent persisting stuff when an error occurs.
- fetch necessary data for application service
- calls application service
- persist updates on entities
Describes necessary external methods for the application to work. It includes repository queries, logger and lock mechanism interfaces.
Calls the application service or the repository directly to read data.
Orchestrate multiple commands when a serie of use cases needs to be called.
Implement high level use cases to respond to player's needs.
Contains domain logic with mostly pure functions.
Core modules represent the different contexts of the application.
There is a similar architecture for every module:
constant
: store every constants needed by the domainvalue
: contains value objects needed by the domainentity
: declare entities used by the domainerror
: declare all errors thrown by the domainservice
: implement business logic when multiple entities are neededtype
: declare additional useful types used in entities
Contains scheduled tasks that call commands and queries of the app.
Contains useful helpers and types that does not fit directly in the model, or call simple external libraries. Prevent from using heavy interfacing with the ports and adapters.
http
file launches a simple HTTP server using middlewares and router.
The router declares all possible endpoints and link it to their corresponding handler.
Defines how the server will respond for every type of request