Skip to content
Snippets Groups Projects
Commit 7932a042 authored by Nicolas Castejon's avatar Nicolas Castejon
Browse files

Merge branch 'services-documentation' into 'master'

Fix some typo + add doc for mail and media library service

See merge request refonte-data/documentation!8
parents 95ec2d94 7482c05d
No related branches found
No related tags found
1 merge request!8Fix some typo + add doc for mail and media library service
Pipeline #1029 passed
......@@ -22,21 +22,21 @@ The entrypoint of the service is a REST API provided by a [NestJS](https://githu
## API documentation
NestJS provides a swagger module that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-docs`.
NestJS provides a [swagger module](https://docs.nestjs.com/recipes/swagger) that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
## Service health
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predifined or custom health indicators. It exposes the health status of the service at `/health`.
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predefined or custom health indicators. It exposes the health status of the service at `/health`.
This service will return a `200` http status code when all indicators are healthy. Otherwise it will return a `503` http status code.
For this service we declared two health indicators that:
For this service we declared two health indicators that verify that:
* the Kong API gateway is up
* the legacy authentication middleware is up
## Stats
We are using a Node module called [swagger-stats](http://swaggerstats.io/).
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alterting.
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alerting.
Those metrics are available at `/swagger-stats/metrics`.
For more information about this module, visit the [official swagger-stat page](http://swaggerstats.io/docs.html).
......
# Mail service
## What it does
This service allow to deliver mails to any email address from the address specified in the configuration. It also provides two particular endpoints, one for the user to give a feedback and another one for general contact purpose. Those endpoints will both send an email to the admin address specified in the configuration.
## How it works
![mail-service](../../assets/mail-service.png)
The entrypoint of the service is a REST API provided by a [NestJS](https://github.com/nestjs/nest) application. The service builds email bodies based on the information it receives and on the provided HTML templates. It then format a JSON with all the properties (to, from, body...) expected by an SMTP server to correctly send an email.
However the service does not send this JSON directly to the distant SMTP server. Indeed as a connection failure might occure, we chose to persist this object in a RabbitMQ queue. Then a small worker written in Node.js will consume the messages from the queue and send it to the SMTP server if correctly formatted. The messages will be removed (acknoledged) from the queue only if the SMTP received the message.
## API documentation
NestJS provides a [swagger module](https://docs.nestjs.com/recipes/swagger) that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
## Service health
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predefined or custom health indicators. It exposes the health status of the service at `/health`.
This service will return a `200` http status code when all indicators are healthy. Otherwise it will return a `503` http status code.
For this service we declared an health indicator that verify that the connection to the RabbitMQ is available.
## Stats
We are using a Node module called [swagger-stats](http://swaggerstats.io/).
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alerting.
Those metrics are available at `/swagger-stats/metrics`.
For more information about this module, visit the [official swagger-stat page](http://swaggerstats.io/docs.html).
## Docker
It is possible to run this service using Docker containers, using the `docker-compose.yml` and `Dockerfile` files.
For more information, refer to the project [service-email][add a link]
\ No newline at end of file
# Media library service
## What it does
This service allows you to upload a file on the [Minio](https://min.io/) instance (compatible with S3) of your choice. The file will be stored in the bucket defined in the configuration of the service.
## How it works
![media-library-service](../../assets/media-library-service.png)
The entrypoint of the service is a REST API provided by a [NestJS](https://github.com/nestjs/nest) application. The service uses the [Javascript MinIO SDK](https://docs.min.io/docs/javascript-client-quickstart-guide.html) to interact with a running instance of Minio.
Before uploading the file, it makes sure that the specified bucket is created. If this is not the case, it creates it with a `public read access`.
The files are folded in sub-buckets as following `/<specified-bucket-name>/<year-YYYY>/<month-MM>/`.
The uploaded file keep its original name but is prefixed by an md5 computed based on its content witch gives the following pattern for file names: `<md5>-<original-name>`. This means that if we upload twice the exact same file, with the same name there will be only one file stored in MinIO.
## API documentation
NestJS provides a [swagger module](https://docs.nestjs.com/recipes/swagger) that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
## Service health
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predefined or custom health indicators. It exposes the health status of the service at `/health`.
This service will return a `200` http status code when all indicators are healthy. Otherwise it will return a `503` http status code.
For this service we implemented a custom health indicator that checks the connection to MinIO giving the total number of buckets when the connection is succesful.
## Stats
We are using a Node module called [swagger-stats](http://swaggerstats.io/).
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alerting.
Those metrics are available at `/swagger-stats/metrics`.
For more information about this module, visit the [official swagger-stat page](http://swaggerstats.io/docs.html).
## Docker
It is possible to run this service using Docker containers, using the `docker-compose.yml` and `Dockerfile` files.
For more information, refer to the project [service-media-library][add a link]
\ No newline at end of file
# Organizations service
## What it does
This service provides a list of organizations with different information about it (such as description, logo..etc).
In our application, one organization is usually a provider of data, used in the Portal Open Data. It can be a public actor or a private one.
......@@ -15,11 +13,11 @@ The entrypoint of the service is a REST API provided by a [NestJS](https://githu
## API documentation
NestJS provides a swagger module that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
NestJS provides a [swagger module](https://docs.nestjs.com/recipes/swagger) that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
## Service health
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predifined or custom health indicators. It exposes the health status of the service at `/health`.
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predefined or custom health indicators. It exposes the health status of the service at `/health`.
This service will return a `200` http status code when all indicators are healthy. Otherwise it will return a `503` http status code.
For this service we declared an health indicator that verifies that it can connect to the database.
......@@ -27,7 +25,7 @@ For this service we declared an health indicator that verifies that it can conne
## Stats
We are using a Node module called [swagger-stats](http://swaggerstats.io/).
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alterting.
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alerting.
Those metrics are available at `/swagger-stats/metrics`.
For more information about this module, visit the [official swagger-stat page](http://swaggerstats.io/docs.html).
......
......@@ -17,11 +17,11 @@ The entrypoint of the service is a REST API provided by a [NestJS](https://githu
## API documentation
NestJS provides a swagger module that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
NestJS provides a [swagger module](https://docs.nestjs.com/recipes/swagger) that can be easily integrated. Using specific annotations alongside your endpoints declaration, this module will automatically generates a swagger documentation, reachable at `/api-doc`.
## Service health
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predifined or custom health indicators. It exposes the health status of the service at `/health`.
NestJS provides a [health module](https://github.com/nestjs/terminus) based on Terminus, that gives you the opportunity to declare predefined or custom health indicators. It exposes the health status of the service at `/health`.
This service will return a `200` http status code when all indicators are healthy. Otherwise it will return a `503` http status code.
For this service we declared an health indicator that verifies that it can connect to the database.
......@@ -29,7 +29,7 @@ For this service we declared an health indicator that verifies that it can conne
## Stats
We are using a Node module called [swagger-stats](http://swaggerstats.io/).
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alterting.
It traces API calls, monitors API performance and usage statistics. It exposes the metrics in different formats, such as Prometheus format, so you may use Prometheus and Graphana for API monitoring and alerting.
Those metrics are available at `/swagger-stats/metrics`.
For more information about this module, visit the [official swagger-stat page](http://swaggerstats.io/docs.html).
......
```plantuml format="png" classes="uml myDiagram" alt="My super diagram placeholder" title="My super diagram" width="300px" height="300px"
Goofy -> MickeyMouse: calls
Goofy <-- MickeyMouse: responds
```
\ No newline at end of file
docs/assets/mail-service.png

29.9 KiB

docs/assets/media-library-service.png

14.2 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment