This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add responseType as a configurable option for browser/electron-based …
…scenarios
- Loading branch information
Showing
22 changed files
with
632 additions
and
486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic | ||
Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.5.0] - 2018-11-18 | ||
### Improved | ||
- Updated outdated packages, moved to gulp 4 and @babel | ||
|
||
### Added | ||
- Added responseType as a configurable option for browser/electron based scenarios | ||
|
||
### Breaking | ||
- Removed `version` function in Net | ||
|
||
### Added | ||
- Started a changelog | ||
- Added badges for downloads/version to Readme | ||
|
||
## [1.4.1] - 2017-11-22 | ||
### Fixed | ||
- Fixed issue where scenario selection went haywire in specific circumstances | ||
|
||
## [1.4.0] - 2017-11-20 | ||
### Improved | ||
- Improved readme in regards to options for data payloads on post/put calls | ||
|
||
### Added | ||
- Added scenario selection for Electron environment | ||
|
||
## [1.3.3] - 2017-10-23 | ||
### Fixed | ||
- Fixed wrong documentation in readme | ||
|
||
## [1.3.2] - 2017-10-21 | ||
### Fixed | ||
- Fixed issue where Scenario blueprint was imported instead of Respond | ||
|
||
## [1.3.1] - 2017-10-21 | ||
### Fixed | ||
- Fixed issue where Scenario blueprint was imported instead of Respond | ||
|
||
## [1.3.0] - 2017-10-20 | ||
### Added | ||
- Prebuild net into a dist folder to prevent people having to build locally | ||
- Add scenario selection for Nodejs | ||
|
||
### Improved | ||
- Cleanup codebase for readability | ||
|
||
### Breaking | ||
- Remove responseType as a configurable options | ||
|
||
## [1.2.6] - 2017-10-18 | ||
### Fixed | ||
- minor bugfixes | ||
|
||
## [1.2.5] - 2017-10-18 | ||
### Fixed | ||
- minor bugfixes | ||
|
||
## [1.2.4] - 2017-10-17 | ||
### Fixed | ||
- minor bugfixes | ||
|
||
## [1.2.3] - 2017-10-17 | ||
### Fixed | ||
- minor bugfixes | ||
|
||
## [1.2.2] - 2017-10-17 | ||
### Fixed | ||
- minor bugfixes | ||
|
||
## [1.2.1] - 2017-10-17 | ||
### Fixed | ||
- Fix issue with key definitions | ||
|
||
## [1.2.0] - 2017-10-16 | ||
### Added | ||
- Add progress handling | ||
- Allow data to be passed to request | ||
- Add querystring parameters as option | ||
|
||
### Improved | ||
- Improve folder/filter structure for better readability | ||
|
||
## [1.1.0] - 2017-08-21 | ||
### Added | ||
- Add MIT License |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
'use strict'; | ||
|
||
// Parses the response to a request and returns an object of form {status, data, headers, options} | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _constants = require("../constants"); | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
// Parses the response to a request and returns an object of form {status, data, headers, options} | ||
var Response = function Response(code) { | ||
var msg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; | ||
var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var msg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; | ||
var headers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; | ||
|
||
_classCallCheck(this, Response); | ||
_classCallCheck(this, Response); | ||
|
||
this.status = code && msg ? { code: code, msg: msg } : undefined; | ||
this.data = (headers['content-type'] || '').indexOf('application/json') > -1 ? JSON.parse(data) : data; | ||
this.headers = headers; | ||
this.status = code && msg ? { | ||
code: code, | ||
msg: msg | ||
} : undefined; | ||
this.data = options.responseType === _constants.RESPONSE_TYPES.JSON || (headers['content-type'] || '').indexOf('application/json') > -1 ? JSON.parse(data) : data; | ||
this.headers = headers; | ||
}; | ||
|
||
exports.default = Response; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1; descriptor.configurable = !0; if ("value" in descriptor) descriptor.writable = !0; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
exports.default = void 0; | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Scenario = function () { | ||
function Scenario() { | ||
_classCallCheck(this, Scenario); | ||
} | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
|
||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
|
||
_createClass(Scenario, null, [{ | ||
key: 'run', | ||
value: function run(options, cb) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
cb(resolve, reject); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
var Scenario = | ||
/*#__PURE__*/ | ||
function () { | ||
function Scenario() { | ||
_classCallCheck(this, Scenario); | ||
} | ||
|
||
_createClass(Scenario, null, [{ | ||
key: "run", | ||
value: function run(options, cb) { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
cb(resolve, reject); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}]); | ||
}); | ||
} | ||
}]); | ||
|
||
return Scenario; | ||
return Scenario; | ||
}(); | ||
|
||
exports.default = Scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
'use strict'; | ||
|
||
// VERBS | ||
'use strict'; // VERBS | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: !0 | ||
value: true | ||
}); | ||
exports.RESPONSE_TYPES = exports.METHODS_ALLOWED_BODY = exports.METHOD = void 0; | ||
|
||
var _Object$freeze; | ||
|
||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
var METHOD = exports.METHOD = Object.freeze({ | ||
GET: 'Get', | ||
PUT: 'Put', | ||
PATCH: 'Patch', | ||
POST: 'Post', | ||
DELETE: 'Delete', | ||
HEAD: 'Head', | ||
OPTIONS: 'Options' | ||
}); | ||
var METHOD = Object.freeze({ | ||
GET: 'Get', | ||
PUT: 'Put', | ||
PATCH: 'Patch', | ||
POST: 'Post', | ||
DELETE: 'Delete', | ||
HEAD: 'Head', | ||
OPTIONS: 'Options' | ||
}); // VERBS Allowed to send data in body | ||
|
||
// VERBS Allowed to send data in body | ||
var METHODS_ALLOWED_BODY = exports.METHODS_ALLOWED_BODY = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, METHOD.PUT, !0), _defineProperty(_Object$freeze, METHOD.POST, !0), _defineProperty(_Object$freeze, METHOD.PATCH, !0), _Object$freeze)); | ||
exports.METHOD = METHOD; | ||
var METHODS_ALLOWED_BODY = Object.freeze((_Object$freeze = {}, _defineProperty(_Object$freeze, METHOD.PUT, true), _defineProperty(_Object$freeze, METHOD.POST, true), _defineProperty(_Object$freeze, METHOD.PATCH, true), _Object$freeze)); // RESPONSE TYPES | ||
|
||
exports.METHODS_ALLOWED_BODY = METHODS_ALLOWED_BODY; | ||
var RESPONSE_TYPES = Object.freeze({ | ||
ARRAY_BUFFER: 'arraybuffer', | ||
BLOB: 'blob', | ||
DOCUMENT: 'document', | ||
JSON: 'json', | ||
TEXT: 'text' | ||
}); | ||
exports.RESPONSE_TYPES = RESPONSE_TYPES; |
Oops, something went wrong.