You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@single9/api-tester

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@single9/api-tester - npm Package Compare versions

Comparing version

to
0.1.5

.github/workflows/npm.yml

40

dist/action.js

@@ -8,2 +8,8 @@ "use strict";

var request_1 = __importDefault(require("request"));
function getOptions(data) {
return Object.assign({
time: true,
json: true,
}, data);
}
var default_1 = /** @class */ (function () {

@@ -15,7 +21,5 @@ function default_1(opts) {

var _this = this;
var options = getOptions(data);
return new Promise(function (resolve, reject) {
request_1.default.get(data.path, {
time: true,
json: true,
}, function (err, resp) {
request_1.default.get(data.path, options, function (err, resp) {
if (err) {

@@ -33,8 +37,5 @@ reject(err);

var _this = this;
var options = getOptions(data);
return new Promise(function (resolve, reject) {
request_1.default.delete(data.path, {
time: true,
json: true,
body: data.body,
}, function (err, resp) {
request_1.default.delete(data.path, options, function (err, resp) {
if (err) {

@@ -52,8 +53,5 @@ reject(err);

var _this = this;
var options = getOptions(data);
return new Promise(function (resolve, reject) {
var sendData = {
encoding: data.encoding,
time: true,
json: true,
};
var sendData = options;
var form = {};

@@ -101,8 +99,5 @@ if (data.uploads) {

var _this = this;
var options = getOptions(data);
return new Promise(function (resolve, reject) {
request_1.default.put(data.path, {
time: true,
json: true,
body: data.body,
}, function (err, resp) {
request_1.default.put(data.path, options, function (err, resp) {
if (err) {

@@ -120,8 +115,5 @@ reject(err);

var _this = this;
var options = getOptions(data);
return new Promise(function (resolve, reject) {
request_1.default.patch(data.path, {
time: true,
json: true,
body: data.body,
}, function (err, resp) {
request_1.default.patch(data.path, options, function (err, resp) {
if (err) {

@@ -128,0 +120,0 @@ reject(err);

@@ -46,2 +46,4 @@ "use strict";

var rootUrl = opts && opts.rootUrl;
var auth = opts && opts.auth;
var headers = opts && opts.headers;
if (!rootUrl)

@@ -55,2 +57,3 @@ throw new Error('rootUrl must be specified');

throw new Error("Duplicated API: " + schema.name);
schema = Object.assign(schema, { auth: auth, headers: headers });
_this[schema.name] = actions(action, rootUrl, schema);

@@ -94,2 +97,4 @@ });

_data.path = rootUrl + _path + (qs && ('?' + qs));
if (!_data.method)
throw new Error("Missing API method: " + _data.name);
act = action[_data.method.toLowerCase()](_data, params);

@@ -96,0 +101,0 @@ act.then(function (resp) {

@@ -25,2 +25,4 @@ import request from 'request';

encoding?: string | null;
headers?: IActionParams['headers'];
auth?: IActionParams['auth'];
}

@@ -30,2 +32,4 @@ export interface IApiSchemaOptions {

showResult?: boolean;
headers?: IActionParams['headers'];
auth?: IActionParams['auth'];
}

@@ -46,3 +50,5 @@ export interface ICallableApiFunction {

tester?: IActionTesterFunction;
headers?: request.Headers;
auth?: request.AuthOptions;
}
export {};

2

package.json
{
"name": "@single9/api-tester",
"version": "0.1.3",
"version": "0.1.5",
"description": "Api Tester",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -30,3 +30,10 @@ Api Tester

// Default: http://localhost:3000
showResult: true // set false to disable results console log
showResult: true, // set false to disable results console log
headers: {
// The headers you want to send. e.g. 'authorization': 'Bearer SAdoweasd...',
},
auth: { // authorization
username: 'username',
password: 'password',
}
})

@@ -33,0 +40,0 @@ ```