Socket
Socket
Sign inDemoInstall

@poppinss/manager

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/manager - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

12

build/src/Manager.js

@@ -12,2 +12,8 @@ "use strict";

exports.Manager = void 0;
const capitalize = (value) => {
if (!value) {
return value;
}
return value.charAt(0).toUpperCase() + value.slice(1);
};
/**

@@ -64,3 +70,5 @@ * Manager class implements the Builder pattern to make instance of similar

makeDriver(mappingName, driver, config) {
const driverCreatorName = `create${driver.replace(/^\w|-\w/g, (g) => g.replace(/^-/, '').toUpperCase())}`;
const driverCreatorName = `create${capitalize(driver.replace(/-\w|_\w/g, (g) => {
return g.substr(1).toUpperCase();
}))}`;
/**

@@ -70,3 +78,3 @@ * Raise error when the parent class doesn't implement the function

if (typeof this[driverCreatorName] !== 'function') {
throw new Error(`"${mappingName}" driver is not supported by "${this.constructor.name}"`);
throw new Error(`"${driver}" driver is not supported by "${this.constructor.name}"`);
}

@@ -73,0 +81,0 @@ const value = this.wrapDriverResponse(mappingName, this[driverCreatorName](mappingName, config));

2

package.json
{
"name": "@poppinss/manager",
"version": "3.0.0",
"version": "3.0.1",
"description": "The builder (Manager) pattern implementation",

@@ -5,0 +5,0 @@ "main": "build/index.js",

<div align="center">
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px">
<img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px">
</div>

@@ -71,13 +71,13 @@

const mailersConfig = {
default: 'transactional',
list: {
transactional: {
driver: 'mailgun'
},
default: 'transactional',
list: {
transactional: {
driver: 'mailgun'
},
promotional: {
driver: 'mailgun'
},
}
promotional: {
driver: 'mailgun'
},
}
}

@@ -92,7 +92,7 @@ ```

class MailManager implements Manager {
protected singleton = true
protected singleton = true
constructor (private config) {
super({})
}
constructor (private config) {
super({})
}
}

@@ -109,19 +109,19 @@ ```

class MailManager implements Manager {
protected singleton = true
protected singleton = true
protected getDefaultMappingName() {
return this.config.default
}
protected getDefaultMappingName() {
return this.config.default
}
protected getMappingConfig(mappingName: string) {
return this.config.list[mappingName]
}
protected getMappingConfig(mappingName: string) {
return this.config.list[mappingName]
}
protected getMappingDriver(mappingName: string) {
return this.config.list[mappingName].driver
}
protected getMappingDriver(mappingName: string) {
return this.config.list[mappingName].driver
}
constructor (private config) {
super({})
}
constructor (private config) {
super({})
}
}

@@ -138,11 +138,11 @@ ```

class MailManager implements Manager {
// ... The existing code
public createMailgun (mappingName, config) {
return new Mailgun(config)
}
// ... The existing code
public createMailgun (mappingName, config) {
return new Mailgun(config)
}
public createSmtp (mappingName, config) {
return new Smtp(config)
}
public createSmtp (mappingName, config) {
return new Smtp(config)
}
}

@@ -157,13 +157,13 @@ ```

const mailersConfig = {
default: 'transactional',
list: {
transactional: {
driver: 'mailgun'
},
default: 'transactional',
list: {
transactional: {
driver: 'mailgun'
},
promotional: {
driver: 'mailgun'
},
}
promotional: {
driver: 'mailgun'
},
}
}

@@ -179,3 +179,3 @@

- They just need to define the mailers config once and get rid of any custom code required to construct individual drivers.
## Extending from outside-in

@@ -188,4 +188,4 @@

mailer.extend('postmark', (container, mappingName, config) => {
return new PostMark(config)
mailer.extend('postmark', (manager, mappingName, config) => {
return new PostMark(config)
})

@@ -196,3 +196,3 @@ ```

- The container object is the value you passed to the Base Manager class using the `super({})` keyword. In case of AdonisJS, it is reference to the IoC container.
- The `manager` object is the reference to the `mailer` object.
- The name of the mapping inside the config file.

@@ -212,3 +212,3 @@ - The actual configuration object.

interface DriverContract {
send (): Promise<void>
send (): Promise<void>
}

@@ -225,3 +225,3 @@ ```

class MailManager implements Manager<
DriverContract
DriverContract
> {

@@ -239,27 +239,27 @@ }

type MailerMappings = {
transactional: Mailgun,
promotional: Mailgun
transactional: Mailgun,
promotional: Mailgun
}
type MailerConfig = {
default: keyof MailerMappings,
list: {
[K in keyof MailerMappings]: any
}
default: keyof MailerMappings,
list: {
[K in keyof MailerMappings]: any
}
}
const mailerConfig: MailerConfig = {
default: 'transactional',
default: 'transactional',
list: {
transactional: {
driver: 'mailgun',
// ...
},
list: {
transactional: {
driver: 'mailgun',
// ...
},
promotional: {
driver: 'mailgun',
// ...
},
}
promotional: {
driver: 'mailgun',
// ...
},
}
}

@@ -274,5 +274,5 @@ ```

class MailManager implements Manager<
DriverContract,
DriverContract,
MailerMappings
DriverContract,
DriverContract,
MailerMappings
> {

@@ -279,0 +279,0 @@ }

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