📦 NPM @3.0.0
☄️ Packosphere @3.0.0
Major Changes
- ☝️ NPM release skipped
v2.x
in order to match Meteor's version (NPM release happened one generation later) ⚠️ New way toimport
andrequire
the packageimport { MailTime, MongoQueue, RedisQueue } from 'mail-time';
⚠️ Decouple from storage, now requires{queue}
passed to constructornew MailTime({})
⚠️ Removedcallback
from.sendMail()
method- 🟥 Added support for Redis as Queue storage driver 🥳
- 🍃 MongoDB as optional Queue storage driver 🥳
- ☝️ Now
josk
task manager and Queue driver can use different databases
Whats' new
- ✨
ping()
method - ✨
cancelMail()
method - ✨
onSent()
callback option - ✨ new
opts.josk
option forjosk
library-specific options - ✨ new
opts.queue
option for storage-driver - ✨
opts.retryDelay
retry delay in ms, successor toopts.interval
- ✨
opts.retries
quantity of retry attempts, successor toopts.maxTries
- ✨
opts.concatDelay
concatenation delay in ms, successor toopts.concatThrottling
- 👨🔬 A lot of new improved tests
- 📔 Custom Queue API
Changes
- ☝️
.sendMail()
now returns{Promise<string>}
that can get passed into.cancelMail()
method
Dependencies
- 📦
[email protected]
, wasv3.1.1
- 📦
[email protected]
, wasv4.2.2
Dev Dependencies
- 📦
[email protected]
, wasv4.4.1
- 📦
[email protected]
, wasv10.3.0
- 📦 Added
[email protected]
Migrate to v3
Import was in v1
/v2
:
import MailTime from 'mail-time';
Changed in v3
to:
import { MailTime, MongoQueue, RedisQueue } from 'mail-time';
new MailTime
in v3
Constructor was in v1
/v2
:
new MailTime({
db,
})
Changed in v3
to:
new MailTime({
queue: new MongoQueue({ db }),
josk: {
adapter: {
type: 'mongo',
db: db
}
}
})
prefix
in v3
Constructor was in v1
/v2
:
new MailTime({
db,
prefix: 'prefix'
})
prefix
need to get duplicated in queue
constructor in v3
:
new MailTime({
prefix: 'prefix',
queue: new MongoQueue({
db: db,
prefix: 'prefix',
}),
josk: {
adapter: {
type: 'mongo',
db: db,
}
}
})
sent/failed callback in v3
Constructor was in v1
/v2
:
MailTime#sendMail(message, (error, details) => {
console.log({error, details})
});
Callbacks are removed in v3
, onError
and onSent
should be used instead:
const mailQueue = new MailTime({
queue: new MongoQueue({ db }),
josk: {
adapter: { type: 'mongo', db }
},
onError(error, email, details) {
console.log(`Email "${email.mailOptions.subject}" wasn't sent to ${email.mailOptions.to}`, error, details);
},
onSent(email, details) {
console.log(`Email "${email.mailOptions.subject}" successfully sent to ${email.mailOptions.to}`, details);
},
});
await mailQueue.sendMail(message);