@maioradv/nestjs-core 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,15 @@
1
1
  import { AccountsApiConfigs } from "@maioradv/accounts-lib";
2
2
  export type MaiorConfig = {
3
3
  accounts?: AccountsApiConfigs;
4
+ smtp?: SmtpConfig;
5
+ };
6
+ export type SmtpConfig = {
7
+ host: string;
8
+ port: number;
9
+ secure: boolean;
10
+ auth: {
11
+ user: string;
12
+ pass: string;
13
+ };
4
14
  };
5
15
  export declare const MaiorConfigKey = "maior";
@@ -2,3 +2,4 @@ export * from './crypt.service';
2
2
  export * from './s3.service';
3
3
  export * from './accounts.service';
4
4
  export * from './storage.service';
5
+ export * from './mailer.service';
@@ -18,3 +18,4 @@ __exportStar(require("./crypt.service"), exports);
18
18
  __exportStar(require("./s3.service"), exports);
19
19
  __exportStar(require("./accounts.service"), exports);
20
20
  __exportStar(require("./storage.service"), exports);
21
+ __exportStar(require("./mailer.service"), exports);
@@ -0,0 +1,21 @@
1
+ import { ConfigService } from "@nestjs/config";
2
+ import { SentMessageInfo, Transporter } from "nodemailer";
3
+ /** From email as email or ['From Name',email]
4
+ * @example user@email.com
5
+ * @example ['User Name','user@email.com']
6
+ */
7
+ export type MailingAddress = string | [string, string];
8
+ export type ReceiverAddress = MailingAddress[];
9
+ export declare class MailerService {
10
+ private readonly config;
11
+ readonly client: Transporter<SentMessageInfo>;
12
+ private sdkConfigs;
13
+ constructor(config: ConfigService);
14
+ sendMail({ from, to, subject, html, text, }: {
15
+ from: MailingAddress;
16
+ to: ReceiverAddress;
17
+ subject: string;
18
+ html: string;
19
+ text?: string;
20
+ }): Promise<void>;
21
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MailerService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const config_1 = require("@nestjs/config");
15
+ const nodemailer_1 = require("nodemailer");
16
+ let MailerService = class MailerService {
17
+ constructor(config) {
18
+ this.config = config;
19
+ this.sdkConfigs = this.config.get('maior.smtp');
20
+ this.client = (0, nodemailer_1.createTransport)({
21
+ ...this.sdkConfigs
22
+ });
23
+ }
24
+ async sendMail({ from, to, subject, html, text, }) {
25
+ return this.client.sendMail({
26
+ from: Array.isArray(from) ? `"${from[0]}" <${from[1]}>` : from,
27
+ to: to.map(a => Array.isArray(a) ? `"${a[0]}" <${a[1]}>` : a).join(', '),
28
+ subject,
29
+ text,
30
+ html,
31
+ });
32
+ }
33
+ };
34
+ exports.MailerService = MailerService;
35
+ exports.MailerService = MailerService = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __metadata("design:paramtypes", [config_1.ConfigService])
38
+ ], MailerService);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maioradv/nestjs-core",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "NestJS helpers by MaiorADV",
5
5
  "repository": "https://github.com/maioradv/nestjs-core.git",
6
6
  "author": "Maior ADV Srl",
@@ -30,12 +30,14 @@
30
30
  "class-validator": "^0.14.1",
31
31
  "image-size": "^1.1.1",
32
32
  "nest-winston": "^1.10.0",
33
+ "nodemailer": "^6.9.14",
33
34
  "winston": "^3.13.0",
34
35
  "winston-daily-rotate-file": "^5.0.0"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@types/multer": "^1.4.11",
38
39
  "@types/node": "^20.12.13",
40
+ "@types/nodemailer": "^6.4.15",
39
41
  "ts-node": "^10.9.2",
40
42
  "typescript": "^5.4.5"
41
43
  },
@@ -49,11 +51,13 @@
49
51
  "@nestjs/platform-express": "^10.0.0",
50
52
  "@nestjs/swagger": "^7.3.1",
51
53
  "@types/multer": "^1.4.11",
54
+ "@types/nodemailer": "^6.4.15",
52
55
  "bcrypt": "^5.1.1",
53
56
  "class-transformer": "^0.5.1",
54
57
  "class-validator": "^0.14.1",
55
58
  "image-size": "^1.1.1",
56
59
  "nest-winston": "^1.10.0",
60
+ "nodemailer": "^6.9.14",
57
61
  "winston": "^3.13.0",
58
62
  "winston-daily-rotate-file": "^5.0.0"
59
63
  },