@octokit/webhooks
Advanced tools
Comparing version 10.5.1 to 10.6.0
@@ -205,3 +205,8 @@ 'use strict'; | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) return Promise.resolve(request.body); | ||
if (request.body) { | ||
if (typeof request.body !== "string") { | ||
console.error("[@octokit/webhooks] Passing the payload as a JSON object in `request.body` is deprecated and will be removed in a future release of `@octokit/webhooks`, please pass it as a a `string` instead."); | ||
} | ||
return Promise.resolve(request.body); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -215,3 +220,5 @@ let data = ""; | ||
try { | ||
resolve(JSON.parse(data)); | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
resolve(data); | ||
} catch (error) { | ||
@@ -218,0 +225,0 @@ error.message = "Invalid JSON"; |
@@ -6,4 +6,8 @@ // @ts-ignore to address #245 | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) | ||
if (request.body) { | ||
if (typeof request.body !== "string") { | ||
console.error("[@octokit/webhooks] Passing the payload as a JSON object in `request.body` is deprecated and will be removed in a future release of `@octokit/webhooks`, please pass it as a a `string` instead."); | ||
} | ||
return Promise.resolve(request.body); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -17,3 +21,5 @@ let data = ""; | ||
try { | ||
resolve(JSON.parse(data)); | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
resolve(data); | ||
} | ||
@@ -20,0 +26,0 @@ catch (error) { |
import { WebhookEvent } from "@octokit/webhooks-types"; | ||
type IncomingMessage = any; | ||
export declare function getPayload(request: IncomingMessage): Promise<WebhookEvent>; | ||
export declare function getPayload(request: IncomingMessage): Promise<WebhookEvent | string>; | ||
export {}; |
@@ -460,4 +460,8 @@ import AggregateError from 'aggregate-error'; | ||
// See https://github.com/octokit/webhooks.js/pull/23 | ||
if (request.body) | ||
if (request.body) { | ||
if (typeof request.body !== "string") { | ||
console.error("[@octokit/webhooks] Passing the payload as a JSON object in `request.body` is deprecated and will be removed in a future release of `@octokit/webhooks`, please pass it as a a `string` instead."); | ||
} | ||
return Promise.resolve(request.body); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -471,3 +475,5 @@ let data = ""; | ||
try { | ||
resolve(JSON.parse(data)); | ||
// Call JSON.parse() only to check if the payload is valid JSON | ||
JSON.parse(data); | ||
resolve(data); | ||
} | ||
@@ -474,0 +480,0 @@ catch (error) { |
{ | ||
"name": "@octokit/webhooks", | ||
"description": "GitHub webhook events toolset for Node.js", | ||
"version": "10.5.1", | ||
"version": "10.6.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
210143
1804