This is a practical work for the class of Object-Oriented Concepts at ISEN Lille. The goal is to explore a few design patterns while building a practical API, and practicing our Typescript skills.
- Answers
- Get started
- Running a command in a running container
- Running a command in a stopped/failed container
- Access your container
- For this exercise, I chose to write a RESTful-compliant API. It is a little bit dirty but commented. I'll leave more room for improvements in the next exercises.
- To compose this model, we need to respect the interface segregation principle. We can describe the data with a bunch of interfaces nested into each other.
- To seperate the service part from the HTTP part, we need to respect the single-responsibility principle. We'll use a light implementation of the
Repository Pattern
, with theStorageAccess
accessing and mapping the data to real objects, and theOrderServer
handling all the business logic. - To anonymize our contact data, we'll use the
Proxy Pattern
. By adding anIStorageAccess
interface to ourStorageAccess
, we will allow the creation of a new classOrderAnonymizer
that will implementsIStorageAccess
and will replacestorageAccess
in ourOrderServer
class.OrderAnonymizer
itself is just calling anAccessStorage
object except for theget()
function where it will alterate the data to remove contacts informations. - I don't see much to do here, I don't really want my
Order
class to manage the Redis connection, it seems to make no sense. - See below for the class diagram
Ensure you have make
installed on your system.
After cloning the repository, run:
make init
Now you can start|stop|restart
your server by running:
make start|stop|restart
Your server will listen by default on port 1337
of your $DOCKER_HOST
You can access the server logs by running:
make log
If you want to stop and destroy your docker containers:
make down
Launch dependencies install with:
make install
To run a command in your container, run the following:
docker exec <container_name> <command>
You will have to run a command through docker-compose
:
docker-compose run --rm <service_name> <command>
To connect to a container, run:
docker exec -ti <container_name> sh