Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

# ------------------------------------------------
# Project
# ------------------------------------------------
PROJECT_CODE=polo
PROJECT_CODE=name
ENV_NAME=main
DOMAIN_NAME=domain.com

NODE_ENV=development
PORT=3000
API_URI=http://localhost:4200/api
PWA_URL=http://localhost:4200

# ------------------------------------------------
# Database
Expand All @@ -24,16 +28,22 @@ TRACTR_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRE
FILE_STORAGE_ACCESS_KEY=minio
FILE_STORAGE_SECRET_KEY=password
FILE_STORAGE_ENDPOINT=localhost
FILE_STORAGE_PORT=9000
FILE_STORAGE_DEFAULT_BUCKET=bucket
FILE_STORAGE_USE_SSL=false
FILE_STORAGE_PORT=9000

#---------------------------------------
# Authentication
#---------------------------------------
COOKIE_SECRET=secret
JWT_SECRET=secret
# ------------------------------------------------
# Terraform
# ------------------------------------------------
TERRAFORM_REMOTE_BACKEND_HOST=host
TERRAFORM_REMOTE_BACKEND_ORG=Organisation_name
TERRAFORM_REMOTE_BACKEND_WORKSPACE=TerraTest
TERRAFORM_REMOTE_BACKEND_TOKEN=token

#---------------------------------------
# Api
#---------------------------------------
API_URL=http://localhost:4200/api
# ------------------------------------------------
# Aws
# ------------------------------------------------
AWS_ACCESS_KEY_ID=access_key
AWS_SECRET_ACCESS_KEY=secret_access_key
AWS_REGION=awe_region
AWS_AVAILABILITY_ZONES=aws_zone
56 changes: 54 additions & 2 deletions apps/docs/docs/mailer/mailjet.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,62 @@ tags:
- Package's author: [Benjamin Testé](https://github.com/benjamin1555)
:::


# Install

`npm i --save @tractr/nestjs-mailer`

# Description
# Overview

Nestjs-mailer package is basically a NestJS wrapper around [node-mailjet package](https://www.npmjs.com/package/node-mailjet).

### Authentication

To use Nestjs-mailer you need to provide valid API and secret keys for authentication. Grab your Mailjet API credentials on [Mailjet website](https://app.mailjet.com/).
If you use a .env file just include them as follow:

```
MAILER_PUBLIC_API_KEY=your_mailjet_public_key
MAILER_PRIVATE_API_KEY=your_mailjet_private_key
```

### Send an email

Once the installation process is complete, we can import the Nestjs-mailer into the root AppModule and add the MailerService as a provider.

``` typescript
import { Module } from '@nestjs/common';
import { MailerModule, MailerService } from '@tractr/nestjs-mailer';

@Module({
imports: [
MailerModule.register({
publicApiKey: process.env.MAILER_PUBLIC_API_KEY,
privateApiKey: process.env.MAILER_PRIVATE_API_KEY
}),
]
})
export class AppModule {}
```

The package exposes a send() function and has the following signature:

``` typescript
send(params: mailjet.Email.SendParams): Promise<mailjet.Email.PostResponse | null>
```

To be able to use it, simply inject the MailerService in your class constructor and call its send() function:

``` typescript
constructor(private mailerService: MailerService) {}

async sendEmail() {
try {
const postResponse = await this.mailerService.send(params);
} catch(e) {
console.error(e);
}
}
```

TODO
For a complete list of properties you can pass in the params object, visit [Mailjet API reference](https://dev.mailjet.com/email/reference/send-emails#v3_1_post_send).
106 changes: 106 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.