Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mailgun.js

Package Overview
Dependencies
Maintainers
3
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailgun.js - npm Package Compare versions

Comparing version 3.1.1 to 3.1.2

2

dist/mailgun.js.LICENSE.txt
/*! MIT License © Sindre Sorhus */
/*! mailgun.js v3.1.1 */
/*! mailgun.js v3.1.2 */

@@ -1,5 +0,4 @@

import APIErrorOptions from './interfaces/APIErrorOptions';
export default class APIError extends Error {
export default class APIError extends Error {
status: number | string;

@@ -6,0 +5,0 @@ stack: string;

@@ -28,2 +28,11 @@

const streamToString = (stream: any) => {
const chunks: any = []
return new Promise((resolve, reject) => {
stream.on('data', (chunk: any) => chunks.push(chunk))
stream.on('error', reject)
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
})
}
class Request {

@@ -77,6 +86,10 @@ private username;

if (!response?.ok) {
const message = response?.body && isStream(response.body)
? await streamToString(response.body)
: await response?.json();
throw new APIError({
status: response?.status,
statusText: response?.statusText,
body: await response?.json()
body: { message }
} as APIErrorOptions);

@@ -83,0 +96,0 @@ }

{
"name": "mailgun.js",
"version": "3.1.1",
"version": "3.1.2",
"main": "dist/mailgun.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -44,5 +44,3 @@ const formData = require('form-data'); // importing this way to not have type error in line 13

it('returns error messages', function () {
api.post('/v3/sandbox.mailgun.org/messages').reply(400, {
message: 'Missing parameter \'to\'.'
});
api.post('/v3/sandbox.mailgun.org/messages').reply(400, 'Missing parameter \'to\'.');

@@ -49,0 +47,0 @@ return client.create('sandbox.mailgun.org', {

@@ -72,3 +72,3 @@ // jscs:disable requireDotNotation

.get('/v2/some/resource')
.reply(429, { message: 'Too many requests' });
.reply(429, 'Too many requests');

@@ -75,0 +75,0 @@ const req = new Request({ username: 'api', key: 'key', url: 'https://api.mailgun.com' } as RequestOptions, formData);

Sorry, the diff of this file is too big to display

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