Compare commits

..

3 Commits

Author SHA1 Message Date
7927a72662 2.0.3 2025-10-17 10:23:58 +00:00
d9d318f8c7 fix(tests): Update testing setup and bump deps; add deno.lock and combined Node/Deno/Bun test 2025-10-17 10:23:57 +00:00
d0686ecfe8 fix: correct Mailgun API URL and enhance error handling in MailgunAccount class
- Fixed the incorrect API URL in MailgunAccount class.
- Improved error handling for email sending failures by providing detailed error messages based on response content.
- Updated test file to export the tap.start() function for better module integration.
2025-10-17 08:48:22 +00:00
7 changed files with 9430 additions and 819 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## 2025-10-17 - 2.0.3 - fix(tests)
Update testing setup and bump deps; add deno.lock and combined Node/Deno/Bun test
- Bump dev dependency @git.zone/tstest from ^2.6.1 to ^2.6.2 and dependency @push.rocks/smartrequest from ^4.3.1 to ^4.3.2 in package.json
- Add deno.lock with resolved dependency tree (new lockfile checked in)
- Introduce test/test.node+deno+bun.ts — consolidated tests for Node/Deno/Bun using Qenv and Mailgun integration flows
- Remove the old test/test.ts (replaced by the new multi-runtime test file)
## 2025-10-13 - 2.0.2 - fix(mailgun)
Normalize package scope and modernize Mailgun client: rename package to @apiclient.xyz/mailgun, update dependencies, refactor HTTP handling, fix types, update TS config and CI, refresh docs and tests

8590
deno.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/mailgun",
"version": "2.0.2",
"version": "2.0.3",
"private": false,
"description": "an api abstraction package for mailgun",
"main": "dist_ts/index.js",
@@ -9,22 +9,22 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"test": "(tstest test/ --verbose)",
"build": "(tsbuild --web --allowimplicitany)",
"format": "(gitzone format)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.65",
"@git.zone/tstest": "^2.5.0",
"@git.zone/tstest": "^2.6.2",
"@push.rocks/qenv": "^6.1.3",
"@push.rocks/tapbundle": "^6.0.3",
"@types/node": "^24.7.2"
"@types/node": "^22.0.0"
},
"dependencies": {
"@push.rocks/smartfile": "^11.2.7",
"@push.rocks/smartmail": "^2.1.0",
"@push.rocks/smartrequest": "^4.3.1",
"@push.rocks/smartrequest": "^4.3.2",
"@push.rocks/smartsmtp": "^3.0.3",
"@push.rocks/smartstring": "^4.0.2"
},

1611
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -50,8 +50,10 @@ tap.test('should send a smartmail with empty body', async () => {
});
tap.test('should retrieve a mail using a retrieval url', async () => {
// Note: This test requires a valid message storage URL from a recently sent email
// Storage URLs are available for 3 days after sending via Events API or Mailgun dashboard
const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl(
'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA==',
'https://api.eu.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA==',
);
console.log(result);
@@ -66,4 +68,4 @@ tap.test('should retrieve a mail using a retrieval url', async () => {
}
});
tap.start();
export default tap.start();

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/mailgun',
version: '2.0.2',
version: '2.0.3',
description: 'an api abstraction package for mailgun'
}

View File

@@ -18,7 +18,7 @@ export class MailgunAccount {
this.apiBaseUrl =
this.options.region === 'eu'
? 'https://api.eu.mailgun.net/v3'
: 'https://api..mailgun.net/v3';
: 'https://api.mailgun.net/v3';
}
/**
@@ -127,8 +127,24 @@ export class MailgunAccount {
);
return await response.json();
} else {
console.log(await response.json());
throw new Error('could not send email');
let errorMessage = `HTTP ${response.status}: ${response.statusText}`;
try {
// Get response body as text first
const errorText = await response.text();
console.log(errorText);
// Try to parse as JSON
try {
const errorBody = JSON.parse(errorText);
errorMessage = errorBody.message || JSON.stringify(errorBody);
} catch {
// Not JSON, use plain text
errorMessage = errorText || errorMessage;
}
} catch {
// Couldn't read body at all
}
throw new Error(`could not send email: ${errorMessage}`);
}
} else {
console.log(