@@ -34,9 +34,38 @@ However the service does not send this JSON directly to the distant SMTP server.
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`.
## Templates
In order to generate responsive (on most-popular email clients) email templates, we use the framework [MJML](https://mjml.io/).
## Templates
There are different ways to install it, an easy one is with `npm`.
```bash
npm install-g mjml
```
It uses its own file extention (`.mjml`) and syntax that abstracts the whole layer of complexity related to responsive email design. Once the template done and the content updated we can convert the mjml syntax to html using the following command:
```
mjml my-file.mjml -o my-file.html
```
As we needed to add some dynamic content in our mails, we used the power of template literals. Indeed when we want to add some dynamic content in the template, we used the following syntax:
```ts
${myVariableName}
```
Once the html is generated, we copy it inside a template literal and put it inside a js function. This function is taking parameters which corresponds to the name of the variables inside the template. As the function also returns the email body as template literal the `${variableName}` will automatically replaced. Here is an example.