mailtrap-nodejs
mailtrap-nodejs copied to clipboard
Restructure SDK
Motivation
- The general and testing APIs are created lazily, after the first access to the corresponding getters.
- Missing params for the Testing API (here) are treated as errors (throw new Error(...)), not warnings.
- Updated the
MailtrapClient
to accept two more params:bulk: Boolean
andsandbox: Boolean
. They are changing the behavior of the send method of the client in the following way:
let host
if (this.bulk && this.sandbox) {
throw new Error('bulk mode is not applicable for sandbox API');
}
else if (this.sandbox) {
host = TESTING_ENDPOINT; // should be sandbox.api.mailtrap.io
}
else if (this.bulk) {
host = BULK_SENDING_ENDPOINT;
}
else {
host = SENDING_ENDPOINT;
}
In the sandbox mode, the client.send
sends the email to the sandbox
, in the bulk mode - to the Bulk API.
- Removes send methods from the
BulkSendingAPI
andTestingAPI
classes. There should be only one send method on theMailtrapClient
that will behave as described above.
Summary by CodeRabbit
Release Notes
-
New Features
- Introduced new configuration for CodeQL analysis to enhance code quality checks.
- Added support for bulk email sending in the Mailtrap client.
- New examples for sending emails using Mailtrap and Nodemailer.
-
Bug Fixes
- Improved error handling for incompatible bulk and sandbox modes in the Mailtrap client.
- Added a new error message for bulk mode incompatibility with the sandbox API.
-
Documentation
- Updated the README for better clarity on version compatibility.
-
Tests
- Enhanced test coverage for MailtrapClient with new scenarios.
- Removed outdated tests related to bulk email functionality.
- Streamlined tests for the Testing class, focusing on essential functionality.
- Updated import paths in examples for consistency and maintainability.