@openinc/parse-server-opendash 2.3.6 → 2.3.7

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.
package/dist/config.js CHANGED
@@ -209,6 +209,15 @@ const options = {
209
209
  public: false,
210
210
  description: "This will force the schema to be updated on startup including removing fields and classes, which is a destructive operation and can result in data loss.",
211
211
  },
212
+ EMAIL_TEMPLATE_DIR: {
213
+ env: "OPENINC_PARSE_EMAIL_TEMPLATE_DIR",
214
+ type: "string",
215
+ required: false,
216
+ secret: false,
217
+ public: false,
218
+ description: "...",
219
+ default: "views/emails",
220
+ },
212
221
  SMTP_ENABLED: {
213
222
  env: "OPENINC_PARSE_SMTP_ENABLED",
214
223
  type: "boolean",
@@ -1,7 +1,4 @@
1
- import { Transporter } from "nodemailer";
2
- import type SMTPTransport from "nodemailer/lib/smtp-transport";
3
1
  import { Core_Email } from "../types";
4
- export declare let transport: Transporter<SMTPTransport.SentMessageInfo> | undefined;
5
2
  export declare function initEmailTransport(): Promise<void>;
6
3
  export declare function sendSimpleEmail(to: string, subject: string, text: string): Promise<Core_Email>;
7
4
  export declare function sendTemplateEmail({ to, subject, fallback, template, data, }: {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.init = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.initEmailTransport = exports.transport = void 0;
6
+ exports.init = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.initEmailTransport = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const nodemailer_1 = __importDefault(require("nodemailer"));
9
9
  const nunjucks_1 = __importDefault(require("nunjucks"));
@@ -11,12 +11,12 @@ const path_1 = require("path");
11
11
  const __1 = require("..");
12
12
  const config_1 = require("../config");
13
13
  const types_1 = require("../types");
14
- const emailTemplateDir = (0, path_1.resolve)(process.cwd(), "views/emails");
15
- exports.transport = undefined;
14
+ let emailTemplateDir = "";
15
+ let transport = undefined;
16
16
  async function initEmailTransport() {
17
17
  try {
18
18
  if (config_1.config.getBoolean("SMTP_ENABLED")) {
19
- exports.transport = nodemailer_1.default.createTransport({
19
+ transport = nodemailer_1.default.createTransport({
20
20
  host: config_1.config.get("SMTP_HOST"),
21
21
  port: config_1.config.getNumber("SMTP_PORT"),
22
22
  secure: config_1.config.getBoolean("SMTP_SECURE"),
@@ -26,7 +26,8 @@ async function initEmailTransport() {
26
26
  pass: config_1.config.get("SMTP_PASS"),
27
27
  },
28
28
  });
29
- await exports.transport.verify();
29
+ await transport.verify();
30
+ emailTemplateDir = (0, path_1.resolve)(process.cwd(), config_1.config.get("EMAIL_TEMPLATE_DIR"));
30
31
  nunjucks_1.default.configure(emailTemplateDir, { autoescape: true });
31
32
  }
32
33
  }
@@ -82,14 +83,14 @@ async function init() {
82
83
  (0, __1.beforeSaveHook)(types_1.Core_Email, async (request) => {
83
84
  const { object } = request;
84
85
  object.setACL(new Parse.ACL());
85
- if (!exports.transport) {
86
+ if (!transport) {
86
87
  object.sent = false;
87
88
  object.success = false;
88
89
  object.error = false;
89
90
  }
90
91
  else {
91
92
  try {
92
- const response = await exports.transport.sendMail({
93
+ const response = await transport.sendMail({
93
94
  ...object.payload,
94
95
  from: config_1.config.get("SMTP_FROM"),
95
96
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "Parse Server Cloud Code for open.DASH",
5
5
  "keywords": [
6
6
  "parse",