node-ninjacat
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -77,2 +77,6 @@ declare namespace Ninjacat { | ||
interface ErrorResponse { | ||
error_message: string; | ||
} | ||
type ReportResponse = ReportPending | ReportRunning | ReportReady; | ||
@@ -79,0 +83,0 @@ |
@@ -11,2 +11,5 @@ "use strict"; | ||
const JSONStream_1 = __importDefault(require("JSONStream")); | ||
function isError(response) { | ||
return (response && response.error_message != undefined); | ||
} | ||
class NinjacatClient { | ||
@@ -45,3 +48,3 @@ constructor(opts) { | ||
return new Promise((resolve, reject) => { | ||
request_1.default.get(`https://app.ninjacat.io/${path}`, config, function processReportGet(err, _res, body) { | ||
request_1.default.get(`https://app.ninjacat.io/${path}`, config, function processReportGet(err, res, body) { | ||
if (err) { | ||
@@ -51,3 +54,15 @@ reject(err); | ||
} | ||
resolve(body); | ||
const { statusCode } = res; | ||
if (statusCode < 200 || statusCode > 301) { | ||
if (!body) { | ||
reject(`Recieved status code ${statusCode}`); | ||
} | ||
return; | ||
} | ||
if (isError(body)) { | ||
reject(body.error_message); | ||
} | ||
else { | ||
resolve(body); | ||
} | ||
}); | ||
@@ -80,3 +95,3 @@ }); | ||
return new Promise((resolve, reject) => { | ||
request_1.default.post(`https://app.ninjacat.io/${path}`, config, function processReportPost(err, _res, body) { | ||
request_1.default.post(`https://app.ninjacat.io/${path}`, config, function processReportPost(err, res, body) { | ||
if (err) { | ||
@@ -86,3 +101,15 @@ reject(err); | ||
} | ||
resolve(body); | ||
const { statusCode } = res; | ||
if (statusCode < 200 || statusCode > 301) { | ||
if (!body) { | ||
reject(`Recieved status code ${statusCode}`); | ||
} | ||
return; | ||
} | ||
if (isError(body)) { | ||
reject(body.error_message); | ||
} | ||
else { | ||
resolve(body); | ||
} | ||
}); | ||
@@ -89,0 +116,0 @@ }); |
{ | ||
"name": "node-ninjacat", | ||
"description": "Reporting & Management API Client for https://www.ninjacat.io/", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"main": "./lib/Client.js", | ||
@@ -6,0 +6,0 @@ "types": "./lib/Client.d.ts", |
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
15941
320