Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sendim

Package Overview
Dependencies
Maintainers
1
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sendim - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

5

dist/sendim.cjs.development.js

@@ -46,3 +46,4 @@ 'use strict';

var SendimTransportInterface = function SendimTransportInterface(_config) {};
var SendimTransportInterface = // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
function SendimTransportInterface(_config) {};
var Sendim = /*#__PURE__*/function () {

@@ -113,3 +114,3 @@ function Sendim(log) {

if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) {
transport = this.transports[0];
transport = this.transports[transportKeys[0]];
} //@ts-ignore

@@ -116,0 +117,0 @@

2

dist/sendim.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=t(require("regenerator-runtime")),e=t(require("pino"));function n(t,r,e,n,a,s,i){try{var o=t[s](i),u=o.value}catch(t){return void e(t)}o.done?r(u):Promise.resolve(u).then(n,a)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(a,s){var i=t.apply(r,e);function o(t){n(i,a,s,o,u,"next",t)}function u(t){n(i,a,s,o,u,"throw",t)}o(void 0)}))}}exports.Sendim=function(){function t(t){this.transports={},this.logger=e({level:t||"info"})}var n=t.prototype;return n.addTransport=function(){var t=a(r.mark((function t(e,n){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e(n),t.next=3,a.isHealthy();case 3:if(t.sent){t.next=6;break}return this.logger.error("[SENDIM] Transport "+a.providerName+" is not healthy !"),t.abrupt("return");case 6:this.transports[a.providerName]=a;case 7:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),n.sendRawMail=function(){var t=a(r.mark((function t(e,n){var a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[0]),s){t.next=7;break}this.logger.debug("[SENDIM] Send raw email",e),t.next=10;break;case 7:return this.logger.debug("[SENDIM] Send raw email (Transport: "+s.providerName+") ",e),t.next=10,s.sendRawMail(e);case 10:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),n.sendTransactionalMail=function(){var t=a(r.mark((function t(e,n){var a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[0]),s){t.next=7;break}this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+")",e),t.next=10;break;case 7:return this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+" / Transport: "+s.providerName+") ",e),t.next=10,s.sendTransactionalMail(e);case 10:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),t}(),exports.SendimTransportInterface=function(t){};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=t(require("regenerator-runtime")),e=t(require("pino"));function n(t,r,e,n,a,s,i){try{var o=t[s](i),u=o.value}catch(t){return void e(t)}o.done?r(u):Promise.resolve(u).then(n,a)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(a,s){var i=t.apply(r,e);function o(t){n(i,a,s,o,u,"next",t)}function u(t){n(i,a,s,o,u,"throw",t)}o(void 0)}))}}exports.Sendim=function(){function t(t){this.transports={},this.logger=e({level:t||"info"})}var n=t.prototype;return n.addTransport=function(){var t=a(r.mark((function t(e,n){var a;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=new e(n),t.next=3,a.isHealthy();case 3:if(t.sent){t.next=6;break}return this.logger.error("[SENDIM] Transport "+a.providerName+" is not healthy !"),t.abrupt("return");case 6:this.transports[a.providerName]=a;case 7:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),n.sendRawMail=function(){var t=a(r.mark((function t(e,n){var a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[a[0]]),s){t.next=7;break}this.logger.debug("[SENDIM] Send raw email",e),t.next=10;break;case 7:return this.logger.debug("[SENDIM] Send raw email (Transport: "+s.providerName+") ",e),t.next=10,s.sendRawMail(e);case 10:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),n.sendTransactionalMail=function(){var t=a(r.mark((function t(e,n){var a,s;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=Object.keys(this.transports),n&&this.transports[n]&&(s=this.transports[n]),!s&&(null==a?void 0:a.length)>0&&(s=this.transports[0]),s){t.next=7;break}this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+")",e),t.next=10;break;case 7:return this.logger.debug("[SENDIM] Send transactional email (Template: "+e.templateId+" / Transport: "+s.providerName+") ",e),t.next=10,s.sendTransactionalMail(e);case 10:case"end":return t.stop()}}),t,this)})));return function(r,e){return t.apply(this,arguments)}}(),t}(),exports.SendimTransportInterface=function(t){};
//# sourceMappingURL=sendim.cjs.production.min.js.map

@@ -40,3 +40,4 @@ import _regeneratorRuntime from 'regenerator-runtime';

var SendimTransportInterface = function SendimTransportInterface(_config) {};
var SendimTransportInterface = // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
function SendimTransportInterface(_config) {};
var Sendim = /*#__PURE__*/function () {

@@ -107,3 +108,3 @@ function Sendim(log) {

if (!transport && (transportKeys == null ? void 0 : transportKeys.length) > 0) {
transport = this.transports[0];
transport = this.transports[transportKeys[0]];
} //@ts-ignore

@@ -110,0 +111,0 @@

{
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",

@@ -57,3 +57,4 @@ "main": "dist/index.js",

],
"preset": "ts-jest"
"preset": "ts-jest",
"testPathIgnorePatterns": ["./node_modules/"]
},

@@ -79,5 +80,4 @@ "devDependencies": {

"dependencies": {
"jest": "^29.4.3",
"pino": "^8.10.0"
}
}
/* eslint-disable @typescript-eslint/ban-ts-comment */
import Pino, {LevelWithSilent} from 'pino';
import Pino, { LevelWithSilent } from 'pino';

@@ -32,2 +32,3 @@ interface EmailInformation {

// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
constructor(_config: object) {}

@@ -41,3 +42,2 @@

export class Sendim {

@@ -47,7 +47,10 @@ transports: Record<string, unknown> = {};

constructor(log?: LevelWithSilent){
constructor(log?: LevelWithSilent) {
this.logger = Pino({ level: log || 'info' });
}
async addTransport<T>(transport: new (...args: any[]) => SendimTransportInterface, config: T) {
async addTransport<T>(
transport: new (...args: any[]) => SendimTransportInterface,
config: T,
) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

@@ -58,3 +61,5 @@ //@ts-ignore

if (!(await newTransport.isHealthy())) {
this.logger.error(`[SENDIM] Transport ${newTransport.providerName} is not healthy !`);
this.logger.error(
`[SENDIM] Transport ${newTransport.providerName} is not healthy !`,
);
return;

@@ -77,3 +82,3 @@ }

if (!transport && transportKeys?.length > 0) {
transport = this.transports[0] as SendimTransportInterface;
transport = this.transports[transportKeys[0]] as SendimTransportInterface;
}

@@ -84,7 +89,9 @@

this.logger.debug(`[SENDIM] Send raw email`, options);
}else {
this.logger.debug(`[SENDIM] Send raw email (Transport: ${transport.providerName}) `, options);
} else {
this.logger.debug(
`[SENDIM] Send raw email (Transport: ${transport.providerName}) `,
options,
);
await transport.sendRawMail(options);
}
}

@@ -111,9 +118,14 @@

if (!transport) {
this.logger.debug(`[SENDIM] Send transactional email (Template: ${options.templateId})`, options);
}else {
this.logger.debug(`[SENDIM] Send transactional email (Template: ${options.templateId} / Transport: ${transport.providerName}) `, options);
this.logger.debug(
`[SENDIM] Send transactional email (Template: ${options.templateId})`,
options,
);
} else {
this.logger.debug(
`[SENDIM] Send transactional email (Template: ${options.templateId} / Transport: ${transport.providerName}) `,
options,
);
await transport.sendTransactionalMail(options);
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc