@usebruno/js 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usebruno/js",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "files": [
package/src/bru.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const Handlebars = require('handlebars');
2
2
  const { cloneDeep } = require('lodash');
3
3
 
4
- const envVariableNameRegex = /^(?!\d)[\w-]*$/;
4
+ const variableNameRegex = /^[\w-.]*$/;
5
5
 
6
6
  class Bru {
7
7
  constructor(envVariables, collectionVariables, processEnvVars, collectionPath) {
@@ -45,12 +45,7 @@ class Bru {
45
45
 
46
46
  setEnvVar(key, value) {
47
47
  if (!key) {
48
- throw new Error('Key is required');
49
- }
50
-
51
- // gracefully ignore if key is not present in environment
52
- if (!this.envVariables.hasOwnProperty(key)) {
53
- return;
48
+ throw new Error('Creating a env variable without specifying a name is not allowed.');
54
49
  }
55
50
 
56
51
  this.envVariables[key] = value;
@@ -58,13 +53,13 @@ class Bru {
58
53
 
59
54
  setVar(key, value) {
60
55
  if (!key) {
61
- throw new Error('Key is required');
56
+ throw new Error('Creating a variable without specifying a name is not allowed.');
62
57
  }
63
58
 
64
- if (envVariableNameRegex.test(key) === false) {
59
+ if (variableNameRegex.test(key) === false) {
65
60
  throw new Error(
66
61
  `Variable name: "${key}" contains invalid characters!` +
67
- ' Names must only contain alpha-numeric characters, "-", "_" and cannot start with a digit.'
62
+ ' Names must only contain alpha-numeric characters, "-", "_", "."'
68
63
  );
69
64
  }
70
65
 
@@ -72,10 +67,10 @@ class Bru {
72
67
  }
73
68
 
74
69
  getVar(key) {
75
- if (envVariableNameRegex.test(key) === false) {
70
+ if (variableNameRegex.test(key) === false) {
76
71
  throw new Error(
77
72
  `Variable name: "${key}" contains invalid characters!` +
78
- ' Names must only contain alpha-numeric characters and cannot start with a digit.'
73
+ ' Names must only contain alpha-numeric characters, "-", "_", "."'
79
74
  );
80
75
  }
81
76
 
@@ -5,6 +5,7 @@ class BrunoResponse {
5
5
  this.statusText = res ? res.statusText : null;
6
6
  this.headers = res ? res.headers : null;
7
7
  this.body = res ? res.data : null;
8
+ this.responseTime = res ? res.responseTime : null;
8
9
  }
9
10
 
10
11
  getStatus() {
@@ -22,6 +23,10 @@ class BrunoResponse {
22
23
  getBody() {
23
24
  return this.res ? this.res.data : null;
24
25
  }
26
+
27
+ getResponseTime() {
28
+ return this.res ? this.res.responseTime : null;
29
+ }
25
30
  }
26
31
 
27
32
  module.exports = BrunoResponse;
package/src/utils.js CHANGED
@@ -109,6 +109,7 @@ const createResponseParser = (response = {}) => {
109
109
  res.statusText = response.statusText;
110
110
  res.headers = response.headers;
111
111
  res.body = response.data;
112
+ res.responseTime = response.responseTime;
112
113
 
113
114
  res.jq = (expr) => {
114
115
  const output = jsonQuery(expr, { data: response.data });