do-you-bench
Advanced tools
Comparing version 2.1.2 to 3.0.0
@@ -6,3 +6,3 @@ module.exports = [ | ||
message: "Enter the number of requests (Int)", | ||
default: 10 | ||
default: 10, | ||
}, | ||
@@ -13,3 +13,3 @@ { | ||
message: "Specify the number of concurrent requests (Int)", | ||
default: 1 | ||
default: 1, | ||
}, | ||
@@ -21,9 +21,22 @@ { | ||
choices: ["http", "https"], | ||
default: "http" | ||
default: "http", | ||
}, | ||
{ | ||
name: "hostname", | ||
name: "method", | ||
type: "list", | ||
message: "Please choose the Method of the request", | ||
choices: ["GET", "POST"], | ||
default: "GET", | ||
}, | ||
{ | ||
name: "postfile", | ||
type: "input", | ||
message: "Please specify a host name", | ||
validate: function(val) { | ||
message: "Please specify the post data file", | ||
when: (answers) => answers.method === "POST", | ||
}, | ||
{ | ||
name: "domain", | ||
type: "input", | ||
message: "Please specify the domain name", | ||
validate: function (val) { | ||
if (val.length) { | ||
@@ -34,3 +47,3 @@ return true | ||
} | ||
} | ||
}, | ||
}, | ||
@@ -41,4 +54,4 @@ { | ||
message: "Please specify a path", | ||
default: "" | ||
} | ||
default: "", | ||
}, | ||
] |
{ | ||
"name": "do-you-bench", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "Simple interactive http[s] benchmarking tool", | ||
@@ -5,0 +5,0 @@ "main": "cli.js", |
@@ -48,3 +48,3 @@ <div align="center"> | ||
- [x] GET | ||
- [ ] POST | ||
- [x] POST | ||
@@ -51,0 +51,0 @@ |
const inquirer = require("inquirer") | ||
const promptQuestion = question => { | ||
const promptQuestion = (question) => { | ||
return inquirer.prompt(question) | ||
@@ -8,3 +8,3 @@ } | ||
module.exports = { | ||
promptQuestion | ||
promptQuestion, | ||
} |
const shell = require("shelljs") | ||
const executeShell = cmd => { | ||
const executeShell = (cmd) => { | ||
shell.exec(cmd) | ||
@@ -8,10 +8,18 @@ } | ||
const generateCommand = (input = {}) => { | ||
return `ab -n ${input.requests} -c ${input.concurrency} ${input.protocol}://www.${ | ||
input.hostname | ||
}/${input.path}` | ||
let command = `ab -n ${input.requests} -c ${input.concurrency} ` | ||
if (input.postfile) { | ||
command = `${command} -p ${input.postfile} -H 'accept: application/json' -H 'Content-Type: application/json' ` | ||
} | ||
return `${command} ${input.protocol}://${input.domain}/${replaceAll(input.path, "/", "")}/` | ||
} | ||
function replaceAll(string = "", character = "", replace = "") { | ||
return string.split(character).join(replace) | ||
} | ||
module.exports = { | ||
executeShell, | ||
generateCommand | ||
generateCommand, | ||
} |
@@ -9,3 +9,3 @@ const { generateCommand } = require("../src/execute") | ||
hostname: "revix.com", | ||
path: "" | ||
path: "", | ||
} | ||
@@ -23,3 +23,3 @@ | ||
hostname: "revix.com", | ||
path: "" | ||
path: "", | ||
} | ||
@@ -26,0 +26,0 @@ |
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
1928744
129