From 8b61d62fe5a1d44e641b106efc8dc07eeb421016 Mon Sep 17 00:00:00 2001 From: "dr.dimitru" Date: Sun, 14 Apr 2024 23:20:06 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=94=20Documentation=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 37 +++++++++++++++++++++++++++++-------- docs/meteor.md | 12 ++++++------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ced10b7..c00e330 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,20 @@ The main difference between *Server* and *Client* `type` is that the *Server* ha - [Installation](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#installation) - [Meteor.js usage](https://github.com/veliovgroup/mail-time/blob/master/docs/meteor.md) - [Usage example](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#basic-usage) - - [Initiate with MongoDB for queue and scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-mongodb-for-queue-and-scheduler) - - [Initiate with MongoDB for queue and Redis for scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-mongodb-for-queue-and-redis-for-scheduler) - - [Initiate with Redis for queue and MongoDB for scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-redis-for-queue-and-mongodb-for-scheduler) - - [Initiate with Redis for queue and scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-redis-for-queue-and-scheduler) + - [Require/Import `mail-time`](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#1-require-package) + - [Create NodeMailer's transports](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#2-create-nodemailers-transports) + - [Initiate `mail-time`](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#3-initiate-mail-time) + - [Connect to Redis](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#3a-initiate-and-connect-to-redis) + - [Connect to MongoDB](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#3b-initiate-and-connect-to-mongodb) + - [Initiate as *Client* instance](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#3c-optionally-create-client-type-of-mailtime) - [Initiate two `MailTime` instances within the single app](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#two-mailtime-instances-usage-example) + - [Use templates](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#passing-variables-to-the-template) + - Different storage configurations: + - [Use MongoDB for queue and scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-mongodb-for-queue-and-scheduler) + - [Use MongoDB for queue and Redis for scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-mongodb-for-queue-and-redis-for-scheduler) + - [Use Redis for queue and MongoDB for scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-redis-for-queue-and-mongodb-for-scheduler) + - [Use Redis for queue and scheduler](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#using-redis-for-queue-and-scheduler) - [API](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#api) - [`new MailTime` *Constructor*](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#new-mailtimeopts-constructor) - [`new RedisQueue` *Constructor*](https://github.com/veliovgroup/mail-time?tab=readme-ov-file#new-redisqueueopts-constructor) @@ -379,8 +387,8 @@ await mailQueue.sendMail({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below MongoDB is used for both ```js -import { MongoClient } from 'mongodb'; import { MailTime, MongoQueue } from 'mail-time'; +import { MongoClient } from 'mongodb'; import { transports } from './transports.js'; const db = (await MongoClient.connect('mongodb://url')).db('database'); @@ -408,8 +416,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below MongoDB is used for queue and Redis is used for scheduler ```js -import { MongoClient } from 'mongodb'; import { MailTime, MongoQueue } from 'mail-time'; +import { MongoClient } from 'mongodb'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -435,8 +443,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below Redis is used for queue and MongoDB is used for scheduler ```js -import { MongoClient } from 'mongodb'; import { MailTime, RedisQueue } from 'mail-time'; +import { MongoClient } from 'mongodb'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -462,8 +470,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below Redis is used for both ```js -import { MongoClient } from 'mongodb'; import { MailTime, RedisQueue } from 'mail-time'; +import { MongoClient } from 'mongodb'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -719,6 +727,19 @@ new MongoQueue({ - `uuid` {*string|promise*} — email's `uuid` returned from `.sendEmail()` method +```js +import { mailQueue } from './mail-queue.js'; + +const uuid = await mailQueue.sendMail({ + to: 'johndoe@example.com', + subject: 'Email subject', + text: 'You have got email!', + html: '

You have got email!

', +}); + +await mailQueue.cancelMail(uuid); +``` + ### `static MailTime.Template` Simple and bulletproof HTML template, see [its source](https://github.com/veliovgroup/mail-time/blob/master/template.html). Usage example: diff --git a/docs/meteor.md b/docs/meteor.md index 6a685ba..7b7a112 100644 --- a/docs/meteor.md +++ b/docs/meteor.md @@ -14,7 +14,7 @@ Install [Atmosphere `ostrio:mailer` package](https://atmospherejs.com/ostrio/mai meteor add ostrio:mailer ``` -Import `'meteor/ostrio:mailer'` package +Import `meteor/ostrio:mailer` package ```js import { MailTime, MongoQueue, RedisQueue } from 'meteor/ostrio:mailer'; @@ -56,8 +56,8 @@ export { transports }; *MailTime* uses separate storage for Queue management and Scheduler. In the example below MongoDB is used for both ```js -import { MongoInternals } from 'meteor/mongo'; import { MailTime, MongoQueue } from 'meteor/ostrio:mailer'; +import { MongoInternals } from 'meteor/mongo'; import { transports } from './transports.js'; const mailQueue = new MailTime({ @@ -90,8 +90,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below MongoDB is used for queue and Redis is used for scheduler ```js -import { MongoInternals } from 'meteor/mongo'; import { MailTime, MongoQueue } from 'meteor/ostrio:mailer'; +import { MongoInternals } from 'meteor/mongo'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -117,8 +117,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below Redis is used for queue and MongoDB is used for scheduler ```js -import { MongoInternals } from 'meteor/mongo'; import { MailTime, RedisQueue } from 'meteor/ostrio:mailer'; +import { MongoInternals } from 'meteor/mongo'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -144,8 +144,8 @@ const mailQueue = new MailTime({ *MailTime* uses separate storage for Queue management and Scheduler. In the example below Redis is used for both ```js -import { MongoInternals } from 'meteor/mongo'; import { MailTime, RedisQueue } from 'meteor/ostrio:mailer'; +import { MongoInternals } from 'meteor/mongo'; import { createClient } from 'redis'; import { transports } from './transports.js'; @@ -184,7 +184,7 @@ REDIS_URL="redis://127.0.0.1:6379" meteor test-packages ./ --driver-package=mete EMAIL_DOMAIN="example.com" REDIS_URL="redis://127.0.0.1:6379" meteor test-packages ./ --driver-package=meteortesting:mocha # In case of the errors, — enable DEBUG for detailed output -DEBUG="true" REDIS_URL="redis://127.0.0.1:6379" meteor test-packages ./ --driver-package=meteortesting:mocha +DEBUG="true" REDIS_URL="redis://127.0.0.1:6379" meteor test-packages ./ --driver-package=meteortesting:mocha # With custom port REDIS_URL="redis://127.0.0.1:6379" meteor test-packages ./ --driver-package=meteortesting:mocha --port 8888