@loomcore/api 0.0.25 → 0.0.27

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.
@@ -47,7 +47,8 @@ export class TestExpressApp {
47
47
  passwordResetTokenExpirationInMinutes: 20
48
48
  },
49
49
  email: {
50
- sendGridApiKey: 'SG.WeDontHaveAKeyYet',
50
+ emailApiKey: 'WeDontHaveAKeyYet',
51
+ emailApiSecret: 'WeDontHaveASecretYet',
51
52
  fromAddress: undefined
52
53
  }
53
54
  });
@@ -24,7 +24,8 @@ export interface IBaseApiConfig {
24
24
  passwordResetTokenExpirationInMinutes: number;
25
25
  };
26
26
  email: {
27
- sendGridApiKey?: string;
27
+ emailApiKey?: string;
28
+ emailApiSecret?: string;
28
29
  fromAddress?: string;
29
30
  systemEmailAddress?: string;
30
31
  };
@@ -1,4 +1,6 @@
1
+ import * as Mailjet from 'node-mailjet';
1
2
  export declare class EmailService {
3
+ private mailjet;
2
4
  constructor();
3
- sendHtmlEmail(emailAddress: string, subject: string, body: string): Promise<void>;
5
+ sendHtmlEmail(emailAddress: string, subject: string, body: string): Promise<Mailjet.LibraryResponse<import("node-mailjet/declarations/request/Request.js").RequestData>>;
4
6
  }
@@ -1,20 +1,38 @@
1
- import sgMail from '@sendgrid/mail';
1
+ import * as Mailjet from 'node-mailjet';
2
2
  import { ServerError } from '../errors/index.js';
3
3
  import { config } from '../config/index.js';
4
4
  export class EmailService {
5
+ mailjet;
5
6
  constructor() {
6
- sgMail.setApiKey(config.email.sendGridApiKey);
7
+ this.mailjet = new Mailjet.default({
8
+ apiKey: config.email.emailApiKey || '',
9
+ apiSecret: config.email.emailApiSecret || ''
10
+ });
7
11
  }
8
12
  async sendHtmlEmail(emailAddress, subject, body) {
9
- const msg = {
10
- to: emailAddress,
11
- from: config.email.fromAddress,
12
- subject: subject,
13
- html: `${body}`,
13
+ const messageData = {
14
+ Messages: [
15
+ {
16
+ From: {
17
+ Email: config.email.fromAddress,
18
+ Name: config.appName || 'Application'
19
+ },
20
+ To: [
21
+ {
22
+ Email: emailAddress
23
+ }
24
+ ],
25
+ Subject: subject,
26
+ HTMLPart: body
27
+ }
28
+ ]
14
29
  };
15
30
  try {
16
- await sgMail.send(msg);
31
+ const result = await this.mailjet
32
+ .post('send', { version: 'v3.1' })
33
+ .request(messageData);
17
34
  console.log(`Email sent to ${emailAddress} with subject ${subject}`);
35
+ return result;
18
36
  }
19
37
  catch (error) {
20
38
  console.error('Error sending email:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb",
6
6
  "scripts": {
@@ -40,8 +40,8 @@
40
40
  "./utils": "./dist/utils/index.js"
41
41
  },
42
42
  "dependencies": {
43
- "@sendgrid/mail": "^8.1.4",
44
- "jsonwebtoken": "^9.0.2"
43
+ "jsonwebtoken": "^9.0.2",
44
+ "node-mailjet": "^6.0.8"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@loomcore/common": "^0.0.13",