medusa-plugin-ses 2.0.8 → 2.0.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Remove extraneous code from index.js
8
+
9
+ ## 2.0.9
10
+
11
+ ### Patch Changes
12
+
13
+ - The API endpoint will now return a more useful error when the templates are not found or compile errors are encountered rather than simply returning false.
14
+
3
15
  ## 2.0.8
4
16
 
5
17
  ### Patch Changes
package/api/index.js CHANGED
@@ -27,9 +27,6 @@ var _default = function _default(app) {
27
27
  if (!success) {
28
28
  throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error);
29
29
  }
30
-
31
- //return res.json(data)
32
-
33
30
  sesService.sendEmail(data.template_id, data.from, data.to, data.data).then(function (result) {
34
31
  return res.json({
35
32
  result: result
package/index.js CHANGED
@@ -1,50 +0,0 @@
1
- const express = require("express")
2
- const { GracefulShutdownServer } = require("medusa-core-utils")
3
-
4
- const loaders = require("@medusajs/medusa/dist/loaders/index").default
5
-
6
- ;(async() => {
7
- async function start() {
8
- const app = express()
9
- const directory = process.cwd()
10
-
11
- try {
12
- const { container } = await loaders({
13
- directory,
14
- expressApp: app
15
- })
16
- const configModule = container.resolve("configModule")
17
- const port = process.env.PORT ?? configModule.projectConfig.port ?? 9000
18
-
19
- const server = GracefulShutdownServer.create(
20
- app.listen(port, (err) => {
21
- if (err) {
22
- return
23
- }
24
- console.log(`Server is ready on port: ${port}`)
25
- })
26
- )
27
-
28
- // Handle graceful shutdown
29
- const gracefulShutDown = () => {
30
- server
31
- .shutdown()
32
- .then(() => {
33
- console.info("Gracefully stopping the server.")
34
- process.exit(0)
35
- })
36
- .catch((e) => {
37
- console.error("Error received when shutting down the server.", e)
38
- process.exit(1)
39
- })
40
- }
41
- process.on("SIGTERM", gracefulShutDown)
42
- process.on("SIGINT", gracefulShutDown)
43
- } catch (err) {
44
- console.error("Error starting server", err)
45
- process.exit(1)
46
- }
47
- }
48
-
49
- await start()
50
- })()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medusa-plugin-ses",
3
- "version": "2.0.8",
3
+ "version": "2.0.10",
4
4
  "description": "AWS SES transactional emails using local handlebars templates",
5
5
  "main": "index.js",
6
6
  "repository": {
package/services/ses.js CHANGED
@@ -253,20 +253,27 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
253
253
  }
254
254
  return _context3.abrupt("return", false);
255
255
  case 2:
256
- _context3.next = 4;
256
+ _context3.prev = 2;
257
+ _context3.next = 5;
257
258
  return this.compileTemplate(template_id, data);
258
- case 4:
259
+ case 5:
259
260
  _yield$this$compileTe2 = _context3.sent;
260
261
  subject = _yield$this$compileTe2.subject;
261
262
  html = _yield$this$compileTe2.html;
262
263
  text = _yield$this$compileTe2.text;
263
264
  if (!(!subject || !html && !text)) {
264
- _context3.next = 10;
265
+ _context3.next = 11;
265
266
  break;
266
267
  }
267
- return _context3.abrupt("return", false);
268
- case 10:
269
- _context3.prev = 10;
268
+ return _context3.abrupt("return", {
269
+ message: "Message not sent. Templates were not found or a compile error was encountered.",
270
+ results: {
271
+ subject: subject,
272
+ html: html,
273
+ text: text
274
+ }
275
+ });
276
+ case 11:
270
277
  return _context3.abrupt("return", this.transporter_.sendMail({
271
278
  from: from,
272
279
  to: to,
@@ -276,13 +283,13 @@ var SESService = /*#__PURE__*/function (_NotificationService) {
276
283
  }));
277
284
  case 14:
278
285
  _context3.prev = 14;
279
- _context3.t0 = _context3["catch"](10);
286
+ _context3.t0 = _context3["catch"](2);
280
287
  throw _context3.t0;
281
288
  case 17:
282
289
  case "end":
283
290
  return _context3.stop();
284
291
  }
285
- }, _callee3, this, [[10, 14]]);
292
+ }, _callee3, this, [[2, 14]]);
286
293
  }));
287
294
  function sendEmail(_x7, _x8, _x9, _x10) {
288
295
  return _sendEmail.apply(this, arguments);