├── test ├── unit │ ├── .gitkeep │ ├── .DS_Store │ ├── fixtures │ │ ├── .DS_Store │ │ └── testcollection │ │ │ └── collection.json │ ├── validation.test.js │ └── convert.test.js ├── .DS_Store ├── .eslintrc └── system │ ├── nsp.test.js │ ├── jsdoc-config.test.js │ └── repository.test.js ├── index.js ├── .nsprc ├── .travis.yml ├── CHANGELOG.md ├── npm ├── test.js ├── test-unit.js ├── test-lint.js └── test-system.js ├── .jsdoc-config.json ├── .gitignore ├── .npmignore ├── package.json ├── lib ├── util.js └── index.js ├── README.md ├── LICENSE ├── LICENSE.md └── .eslintrc /test/unit/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib'); 2 | -------------------------------------------------------------------------------- /.nsprc: -------------------------------------------------------------------------------- 1 | { 2 | "exceptions": [], 3 | "exclusions": [] 4 | } 5 | -------------------------------------------------------------------------------- /test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/postmanlabs/codegen-curl/master/test/.DS_Store -------------------------------------------------------------------------------- /test/unit/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/postmanlabs/codegen-curl/master/test/unit/.DS_Store -------------------------------------------------------------------------------- /test/unit/fixtures/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/postmanlabs/codegen-curl/master/test/unit/fixtures/.DS_Store -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | - "7" 5 | - "8" 6 | - "9" 7 | - "node" 8 | - "lts/*" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # codegen-curl Changelog 2 | 3 | #### v0.1.5 (Novermber 9, 2018) 4 | * Better defaults for indentSize 5 | 6 | #### v0.1.4 (October 22, 2018) 7 | * Removed the silent mode flag from generated snippets 8 | 9 | #### v0.1.3 (May 30, 2018) 10 | * Added `syntax_mode` in `com_postman_plugin` property in package.json 11 | 12 | #### v0.1.1 (May 16, 2018) 13 | * Initial Release -------------------------------------------------------------------------------- /npm/test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var chalk = require('chalk'), 3 | exit = require('shelljs').exit, 4 | prettyms = require('pretty-ms'), 5 | startedAt = Date.now(), 6 | name = require('../package.json').name; 7 | 8 | require('async').series([ 9 | require('./test-lint'), 10 | require('./test-system'), 11 | require('./test-unit') 12 | ], function (code) { 13 | // eslint-disable-next-line max-len 14 | console.info(chalk[code ? 'red' : 'green'](`\n${name}: duration ${prettyms(Date.now() - startedAt)}\n${name}: ${code ? 'not ok' : 'ok'}!`)); 15 | exit(code && (typeof code === 'number' ? code : 1) || 0); 16 | }); 17 | -------------------------------------------------------------------------------- /.jsdoc-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true, 4 | "dictionaries": ["jsdoc", "closure"] 5 | }, 6 | "source": { 7 | "include": [ ], 8 | "includePattern": ".+\\.js(doc)?$", 9 | "excludePattern": "(^|\\/|\\\\)_" 10 | }, 11 | 12 | "plugins": [ 13 | "plugins/markdown" 14 | ], 15 | 16 | "templates": { 17 | "cleverLinks": false, 18 | "monospaceLinks": false, 19 | "highlightTutorialCode" : true 20 | }, 21 | 22 | "opts": { 23 | "template": "./node_modules/postman-jsdoc-theme", 24 | "encoding": "utf8", 25 | "destination": "./out/docs", 26 | "recurse": true, 27 | "readme": "README.md" 28 | }, 29 | 30 | "markdown": { 31 | "parser": "gfm", 32 | "hardwrap": false 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "mocha" 4 | ], 5 | "env": { 6 | "mocha": true, 7 | "node": true, 8 | "es6": true 9 | }, 10 | "rules": { 11 | "mocha/handle-done-callback": "error", 12 | "mocha/max-top-level-suites": "error", 13 | "mocha/no-exclusive-tests": "error", 14 | "mocha/no-global-tests": "error", 15 | "mocha/no-hooks-for-single-case": "off", 16 | "mocha/no-hooks": "off", 17 | "mocha/no-identical-title": "error", 18 | "mocha/no-mocha-arrows": "error", 19 | "mocha/no-nested-tests": "error", 20 | "mocha/no-pending-tests": "error", 21 | "mocha/no-return-and-callback": "error", 22 | "mocha/no-sibling-hooks": "error", 23 | "mocha/no-skipped-tests": "warn", 24 | "mocha/no-synchronous-tests": "off", 25 | "mocha/no-top-level-hooks": "warn", 26 | "mocha/valid-test-description": "off", 27 | "mocha/valid-suite-description": "off" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/unit/validation.test.js: -------------------------------------------------------------------------------- 1 | var expect = require('chai').expect, 2 | path = require('path'), 3 | 4 | package = require(path.resolve('.', 'package.json')); 5 | 6 | 7 | describe('package.json', function () { 8 | it('should have com_postman_plugin object with valid properties', function () { 9 | expect(package).to.have.property('com_postman_plugin'); 10 | 11 | expect(package.com_postman_plugin.type).to.equal('code_generator'); 12 | expect(package.com_postman_plugin.lang).to.be.a('string'); 13 | expect(package.com_postman_plugin.variant).to.be.a('string'); 14 | expect(package.com_postman_plugin.syntax_mode).to.be.equal('powershell'); 15 | }); 16 | it('should have main property with relative path to object with convert property', function () { 17 | var languageModule; 18 | 19 | expect(package.main).to.be.a('string'); 20 | 21 | try { 22 | languageModule = require(path.resolve('.', package.main)); 23 | } 24 | catch (error) { 25 | console.error(error); 26 | } 27 | expect(languageModule).to.be.a('object'); 28 | expect(languageModule.convert).to.be.a('function'); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Prevent IDE stuff 15 | .idea 16 | .vscode 17 | *.sublime-* 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | .coverage 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (http://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Typescript v1 declaration files 45 | typings/ 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Optional REPL history 54 | .node_repl_history 55 | 56 | # Output of 'npm pack' 57 | *.tgz 58 | 59 | # Yarn Integrity file 60 | .yarn-integrity 61 | 62 | # dotenv environment variables file 63 | .env 64 | 65 | out/ 66 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | ### NPM Specific: Disregard recursive project files 2 | ### =============================================== 3 | /.editorconfig 4 | /.gitmodules 5 | /test 6 | 7 | ### Borrowed from .gitignore 8 | ### ======================== 9 | 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Prevent IDE stuff 24 | .idea 25 | .vscode 26 | *.sublime-* 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | lib-cov 30 | 31 | # Coverage directory used by tools like istanbul 32 | .coverage 33 | 34 | # nyc test coverage 35 | .nyc_output 36 | 37 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 38 | .grunt 39 | 40 | # Bower dependency directory (https://bower.io/) 41 | bower_components 42 | 43 | # node-waf configuration 44 | .lock-wscript 45 | 46 | # Compiled binary addons (http://nodejs.org/api/addons.html) 47 | build/Release 48 | 49 | # Dependency directories 50 | node_modules/ 51 | jspm_packages/ 52 | 53 | # Typescript v1 declaration files 54 | typings/ 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | 74 | out/ 75 | -------------------------------------------------------------------------------- /test/system/nsp.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview Ensures nsprc is as expected 3 | */ 4 | 5 | var expect = require('chai').expect, 6 | fs = require('fs'); 7 | 8 | /* global describe, it, before */ 9 | describe('nsp', function () { 10 | var nsprc, 11 | pkg; 12 | 13 | before(function () { 14 | nsprc = JSON.parse(fs.readFileSync('./.nsprc').toString()); 15 | pkg = JSON.parse(fs.readFileSync('./package.json').toString()); 16 | }); 17 | 18 | it('must be a dev dependency', function () { 19 | expect(pkg.devDependencies && pkg.devDependencies.nsp).to.be.ok; 20 | }); 21 | 22 | describe('nsprc', function () { 23 | it('must exist', function () { 24 | expect(nsprc).to.be.ok; 25 | }); 26 | 27 | it('must not have any exclusion', function () { 28 | expect(nsprc.exceptions).to.eql([]); 29 | }); 30 | 31 | it('must exclude only a known set of packages', function () { 32 | expect(nsprc.exclusions).to.eql([]); 33 | }); 34 | 35 | // if you are changing the version here, most probably you are better of removing the exclusion in first place. 36 | // remove the exclusion and check if nsp passes, else update the version here 37 | it('on excluded package\'s version change must reconsider removing exclusion', function () { 38 | // expect(pkg.dependencies).to.have.property('', ''); 39 | }); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@postman/codegen-curl", 3 | "version": "0.1.5", 4 | "description": "Converter plugin to convert from postman sdk request to cURL code snippet", 5 | "com_postman_plugin": { 6 | "type": "code_generator", 7 | "lang": "curl", 8 | "variant": "curl", 9 | "syntax_mode": "powershell" 10 | }, 11 | "main": "index.js", 12 | "scripts": { 13 | "test": "node npm/test.js", 14 | "test-lint": "node npm/test-lint.js", 15 | "test-unit": "node npm/test-unit.js", 16 | "test-system": "node npm/test-system.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git@bitbucket.org:postmanlabs/codegen-curl.git" 21 | }, 22 | "author": "Postman Labs ", 23 | "license": "Apache-2.0", 24 | "homepage": "https://bitbucket.org/postmanlabs/codegen-curl#readme", 25 | "dependencies": { 26 | "lodash": "4.17.5" 27 | }, 28 | "devDependencies": { 29 | "async": "2.6.0", 30 | "chai": "4.1.2", 31 | "chalk": "2.3.2", 32 | "dependency-check": "3.1.0", 33 | "eslint": "4.18.2", 34 | "eslint-plugin-jsdoc": "3.5.0", 35 | "eslint-plugin-lodash": "2.6.1", 36 | "eslint-plugin-mocha": "4.12.1", 37 | "eslint-plugin-security": "1.4.0", 38 | "mocha": "5.0.4", 39 | "newman": "3.9.3", 40 | "nsp": "2.8.0", 41 | "nyc": "11.4.1", 42 | "parse-gitignore": "0.4.0", 43 | "postman-collection": "3.0.7", 44 | "pretty-ms": "3.1.0", 45 | "recursive-readdir": "2.2.2", 46 | "shelljs": "0.8.1" 47 | }, 48 | "engines": { 49 | "node": ">=4" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/util.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | /** 3 | * sanitizes input string by handling escape characters eg: converts '''' to '\'\'' 4 | * and trim input if required 5 | * 6 | * @param {String} inputString 7 | * @param {Boolean} [trim] - indicates whether to trim string or not 8 | * @returns {String} 9 | */ 10 | sanitize: function (inputString, trim) { 11 | if (typeof inputString !== 'string') { 12 | return ''; 13 | } 14 | inputString = inputString.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); 15 | return trim ? inputString.trim() : inputString; 16 | }, 17 | form: function (option, format) { 18 | if (format) { 19 | switch (option) { 20 | case '-s': 21 | return '--silent'; 22 | case '-L': 23 | return '--location'; 24 | case '-m': 25 | return '--max-time'; 26 | case '-I': 27 | return '--head'; 28 | case '-X': 29 | return '--request'; 30 | case '-H': 31 | return '--header'; 32 | case '-d': 33 | return '--data'; 34 | case '-F': 35 | return '--form'; 36 | case '--data-binary': 37 | return '--data-binary'; 38 | default: 39 | return ''; 40 | } 41 | } 42 | else { 43 | return option; 44 | } 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /npm/test-unit.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* eslint-env node, es6 */ 3 | // --------------------------------------------------------------------------------------------------------------------- 4 | // This script is intended to execute all unit tests. 5 | // --------------------------------------------------------------------------------------------------------------------- 6 | 7 | require('shelljs/global'); 8 | 9 | // set directories and files for test and coverage report 10 | var path = require('path'), 11 | 12 | NYC = require('nyc'), 13 | chalk = require('chalk'), 14 | recursive = require('recursive-readdir'), 15 | 16 | COV_REPORT_PATH = '.coverage', 17 | SPEC_SOURCE_DIR = path.join(__dirname, '..', 'test', 'unit'); 18 | 19 | module.exports = function (exit) { 20 | // banner line 21 | console.info(chalk.yellow.bold('Running unit tests using mocha on node...')); 22 | 23 | test('-d', COV_REPORT_PATH) && rm('-rf', COV_REPORT_PATH); 24 | mkdir('-p', COV_REPORT_PATH); 25 | 26 | var Mocha = require('mocha'), 27 | nyc = new NYC({ 28 | reporter: ['text'], 29 | reportDir: COV_REPORT_PATH, 30 | tempDirectory: COV_REPORT_PATH 31 | }); 32 | 33 | nyc.wrap(); 34 | // add all spec files to mocha 35 | recursive(SPEC_SOURCE_DIR, function (err, files) { 36 | if (err) { console.error(err); return exit(1); } 37 | 38 | var mocha = new Mocha({ timeout: 1000 * 60 }); 39 | 40 | files.filter(function (file) { // extract all test files 41 | return (file.substr(-8) === '.test.js'); 42 | }).forEach(mocha.addFile.bind(mocha)); 43 | 44 | mocha.run(function (runError) { 45 | runError && console.error(runError.stack || runError); 46 | 47 | nyc.writeCoverageFile(); 48 | nyc.report(); 49 | exit(runError ? 1 : 0); 50 | }); 51 | }); 52 | }; 53 | 54 | // ensure we run this script exports if this is a direct stdin.tty run 55 | !module.parent && module.exports(exit); 56 | -------------------------------------------------------------------------------- /npm/test-lint.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('shelljs/global'); 3 | 4 | var chalk = require('chalk'), 5 | async = require('async'), 6 | ESLintCLIEngine = require('eslint').CLIEngine, 7 | 8 | /** 9 | * The list of source code files / directories to be linted. 10 | * 11 | * @type {Array} 12 | */ 13 | LINT_SOURCE_DIRS = [ 14 | './lib', 15 | './bin', 16 | './test', 17 | './examples/*.js', 18 | './npm/*.js', 19 | './index.js' 20 | ]; 21 | 22 | module.exports = function (exit) { 23 | // banner line 24 | console.info(chalk.yellow.bold('\nLinting files using eslint...')); 25 | 26 | async.waterfall([ 27 | 28 | /** 29 | * Instantiates an ESLint CLI engine and runs it in the scope defined within LINT_SOURCE_DIRS. 30 | * 31 | * @param {Function} next - The callback function whose invocation marks the end of the lint test run. 32 | * @returns {*} 33 | */ 34 | function (next) { 35 | next(null, (new ESLintCLIEngine()).executeOnFiles(LINT_SOURCE_DIRS)); 36 | }, 37 | 38 | /** 39 | * Processes a test report from the Lint test runner, and displays meaningful results. 40 | * 41 | * @param {Object} report - The overall test report for the current lint test. 42 | * @param {Object} report.results - The set of test results for the current lint run. 43 | * @param {Function} next - The callback whose invocation marks the completion of the post run tasks. 44 | * @returns {*} 45 | */ 46 | function (report, next) { 47 | var errorReport = ESLintCLIEngine.getErrorResults(report.results); 48 | // log the result to CLI 49 | console.info(ESLintCLIEngine.getFormatter()(report.results)); 50 | // log the success of the parser if it has no errors 51 | (errorReport && !errorReport.length) && console.info(chalk.green('eslint ok!')); 52 | // ensure that the exit code is non zero in case there was an error 53 | next(Number(errorReport && errorReport.length) || 0); 54 | } 55 | ], exit); 56 | }; 57 | 58 | // ensure we run this script exports if this is a direct stdin.tty run 59 | !module.parent && module.exports(exit); 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # codegen-curl 2 | 3 | > Converts Postman-SDK Request into code snippet for cURL. 4 | 5 | ## Getting Started 6 | To get a copy on your local machine 7 | ```bash 8 | $ git clone git@github.com:postmanlabs/codegen-curl.git 9 | ``` 10 | 11 | #### Prerequisites 12 | To run this code-generator, ensure that you have NodeJS >= v6. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. 13 | 14 | #### Installing dependencies 15 | ```bash 16 | $ npm install; 17 | ``` 18 | 19 | ## Using the Module 20 | The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to a cURL code snippet. 21 | 22 | ### convert function 23 | The Convert function takes three parameters 24 | 25 | * `request` - Postman-SDK Request Object 26 | 27 | * `options` - options is an object which hsa following properties 28 | * `indentType` - String denoting type of indentation for code snippet. eg: 'space', 'tab' 29 | * `indentCount` - Integer denoting count of indentation required 30 | * `requestBodyTrim` - Boolean denoting whether to trim request body fields 31 | * `followRedirect` - Boolean denoting whether to redirect a request 32 | * `requestTimeout` - Integer denoting time after which the request will bail out in milli-seconds 33 | * `multiLine` - Boolean denoting whether to output code snippet with multi line breaks 34 | * `longFormat` - Boolean denoting whether to use longform cURL options in snippet 35 | 36 | * `callback` - callback function with first parameter as error and second parameter as string for code snippet 37 | 38 | ##### Example: 39 | ```js 40 | var request = new sdk.Request('www.google.com'), //using postman sdk to create request 41 | options = { 42 | indentCount: 3, 43 | indentType: 'space', 44 | requestTimeout: 200, 45 | requestBodyTrim: true, 46 | multiLine: true, 47 | followRedirect: true, 48 | longFormat: true 49 | }; 50 | convert(request, options, function(error, snippet) { 51 | if (error) { 52 | // handle error 53 | } 54 | // handle snippet 55 | }); 56 | ``` 57 | 58 | ### Guidelines for using generated snippet 59 | 60 | * Since the Postman-SDK Request object doesn't provide the complete path of the file, it needs to be manually inserted in case of uploading a file. 61 | 62 | * This module doesn't support cookies. 63 | 64 | 65 | ## Running the tests 66 | 67 | ```bash 68 | $ npm test 69 | ``` 70 | 71 | ### Break down into unit tests 72 | 73 | ```bash 74 | $ npm run test-unit 75 | ``` -------------------------------------------------------------------------------- /test/system/jsdoc-config.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview This test specs runs tests on the ,jsdoc-config.json file of repository. It has a set of strict tests 3 | * on the content of the file as well. Any change to .jsdoc-config.json must be accompanied by valid test case in this 4 | * spec-sheet. 5 | */ 6 | /* global describe, it */ 7 | describe('JSDoc configuration', function () { 8 | var fs = require('fs'), 9 | _ = require('lodash'), 10 | expect = require('chai').expect, 11 | 12 | json, 13 | content, 14 | jsdocConfigPath = './.jsdoc-config.json'; 15 | 16 | it('must exist', function (done) { 17 | fs.stat(jsdocConfigPath, done); 18 | }); 19 | 20 | it('must have readable content', function () { 21 | expect(content = fs.readFileSync(jsdocConfigPath).toString()).to.be.ok; 22 | }); 23 | 24 | it('content must be valid JSON', function () { 25 | expect(json = JSON.parse(content)).to.be.ok; 26 | }); 27 | 28 | describe('tags', function () { 29 | it('must allow unkown tags', function () { 30 | expect(json.tags.allowUnknownTags).to.be.ok; 31 | }); 32 | 33 | it('must have jsdoc and closure dictionaries', function () { 34 | expect(json.tags.dictionaries).to.eql(['jsdoc', 'closure']); 35 | }); 36 | }); 37 | 38 | describe('source', function () { 39 | it('must have an include pattern', function () { 40 | expect(json.source.includePattern).to.equal('.+\\.js(doc)?$'); 41 | }); 42 | 43 | it('must have an exclude pattern', function () { 44 | expect(json.source.excludePattern).to.equal('(^|\\/|\\\\)_'); 45 | }); 46 | }); 47 | 48 | describe('plugins', function () { 49 | it('must have the markdown plugin', function () { 50 | expect(_.includes(json.plugins, 'plugins/markdown')).to.be.ok; 51 | }); 52 | }); 53 | 54 | describe('templates', function () { 55 | it('must not have clever links', function () { 56 | expect(json.templates.cleverLinks).to.not.be.ok; 57 | }); 58 | 59 | it('must not have monospace links', function () { 60 | expect(json.templates.monospaceLinks).to.not.be.ok; 61 | }); 62 | 63 | it('must highlight tutorial code', function () { 64 | expect(json.templates.highlightTutorialCode).to.be.ok; 65 | }); 66 | }); 67 | 68 | describe('opts', function () { 69 | it('must use the Postman JSDoc theme', function () { 70 | expect(json.opts.template).to.equal('./node_modules/postman-jsdoc-theme'); 71 | }); 72 | 73 | it('must use UTF-8 encoding', function () { 74 | expect(json.opts.encoding).to.equal('utf8'); 75 | }); 76 | 77 | it('must create documentation in out/docs', function () { 78 | expect(json.opts.destination).to.equal('./out/docs'); 79 | }); 80 | 81 | it('must recurse', function () { 82 | expect(json.opts.recurse).to.be.ok; 83 | }); 84 | 85 | it('must have a valid readme', function () { 86 | expect(json.opts.readme).to.equal('README.md'); 87 | }); 88 | }); 89 | 90 | describe('markdown', function () { 91 | it('must have a gfm parser', function () { 92 | expect(json.markdown.parser).to.equal('gfm'); 93 | }); 94 | 95 | it('must have jsdoc and closure dictionaries', function () { 96 | expect(json.markdown.hardwrap).to.not.be.ok; 97 | }); 98 | }); 99 | }); 100 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var sanitize = require('./util').sanitize, 2 | form = require('./util').form, 3 | _ = require('lodash'); 4 | 5 | module.exports = { 6 | convert: function (request, options, callback) { 7 | 8 | if (!_.isFunction(callback)) { 9 | throw new Error('Curl-Converter: callback is not valid function'); 10 | } 11 | 12 | var indent, trim, headersData, body, text, redirect, timeout, multiLine, format, snippet, silent; 13 | redirect = options.followRedirect || _.isUndefined(options.followRedirect); 14 | timeout = options.requestTimeout ? options.requestTimeout : 0; 15 | multiLine = options.multiLine || _.isUndefined(options.multiLine); 16 | format = options.longFormat || _.isUndefined(options.longFormat); 17 | trim = options.trimRequestBody ? options.trimRequestBody : false; 18 | silent = options.silent ? options.silent : false; 19 | 20 | snippet = silent ? `curl ${form('-s', format)}` : 'curl'; 21 | if (redirect) { 22 | snippet += ` ${form('-L', format)}`; 23 | } 24 | if (timeout > 0) { 25 | snippet += ` ${form('-m', format)} ${timeout}`; 26 | } 27 | if (multiLine) { 28 | indent = options.indentType === 'tab' ? '\t' : ' '; 29 | indent = ' \\\n' + indent.repeat(options.indentCount || (options.indentType === 'tab' ? 1 : 4)); 30 | } 31 | else { 32 | indent = ' '; 33 | } 34 | 35 | if (request.method === 'HEAD') { 36 | snippet += ` ${form('-I', format)} "${encodeURI(request.url.toString())}"`; 37 | } 38 | else { 39 | snippet += ` ${form('-X', format)} ${request.method} "${encodeURI(request.url.toString())}"`; 40 | } 41 | 42 | headersData = request.getHeaders({ enabled: true }); 43 | _.forEach(headersData, function (value, key) { 44 | snippet += indent + `${form('-H', format)} "${key}: ${value}"`; 45 | }); 46 | 47 | body = request.body.toJSON(); 48 | 49 | if (!_.isEmpty(body)) { 50 | switch (body.mode) { 51 | case 'urlencoded': 52 | text = []; 53 | _.forEach(body.urlencoded, function (data) { 54 | if (!data.disabled) { 55 | text.push(`${escape(data.key)}=${escape(data.value)}`); 56 | } 57 | }); 58 | snippet += indent + `${form('-d', format)} "${text.join('&')}"`; 59 | break; 60 | case 'raw': 61 | snippet += indent + `${form('-d', format)} "${sanitize(body.raw.toString(), trim)}"`; 62 | break; 63 | case 'formdata': 64 | _.forEach(body.formdata, function (data) { 65 | if (!(data.disabled)) { 66 | if (data.type === 'file') { 67 | snippet += indent + `${form('-F', format)}`; 68 | snippet += ` "${sanitize(data.key, trim)}=@${sanitize(data.src, trim)}"`; 69 | } 70 | else { 71 | snippet += indent + `${form('-F', format)}`; 72 | snippet += ` "${sanitize(data.key, trim)}=${sanitize(data.value, trim)}"`; 73 | } 74 | } 75 | }); 76 | break; 77 | case 'file': 78 | snippet += indent + `${form('--data-binary', format)}`; 79 | snippet += ` "${sanitize(body.key, trim)}=@${sanitize(body.value, trim)}"`; 80 | break; 81 | default: 82 | snippet += `${form('-d', format)} ""`; 83 | } 84 | } 85 | callback(null, snippet); 86 | }, 87 | getOptions: function () { 88 | return [ 89 | { 90 | name: 'MultiLine Curl Request', 91 | id: 'multiLine', 92 | type: 'boolean', 93 | default: true, 94 | description: 'denoting whether to get the request in single or multiple lines' 95 | }, 96 | { 97 | name: 'Long Format', 98 | id: 'longFormat', 99 | type: 'boolean', 100 | default: true, 101 | description: 'denoting whether to get the request in short form or long form' 102 | } 103 | ]; 104 | } 105 | }; 106 | -------------------------------------------------------------------------------- /npm/test-system.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('shelljs/global'); 3 | 4 | var chalk = require('chalk'), 5 | async = require('async'), 6 | _ = require('lodash'), 7 | path = require('path'), 8 | Mocha = require('mocha'), 9 | recursive = require('recursive-readdir'), 10 | 11 | /** 12 | * The source directory for system test specs. 13 | * 14 | * @type {String} 15 | */ 16 | SPEC_SOURCE_DIR = './test/system', 17 | 18 | /** 19 | * Load a JSON from file synchronously, used as an alternative to dynamic requires. 20 | * 21 | * @param {String} file - The path to the JSON file to load from. 22 | * @returns {Object} - The parsed JSON object contained in the file at the provided path. 23 | * @throws {SyntaxError} - Throws an error if the provided JSON file is invalid. 24 | */ 25 | loadJSON = function (file) { 26 | return JSON.parse(require('fs').readFileSync(path.join(__dirname, file)).toString()); 27 | }; 28 | 29 | module.exports = function (exit) { 30 | // banner line 31 | console.info(chalk.yellow.bold('\nRunning system tests...\n')); 32 | 33 | async.series([ 34 | 35 | /** 36 | * Enforces sanity checks on installed packages via dependency-check. 37 | * 38 | * @param {Function} next - The callback function invoked when the package sanity check has concluded. 39 | * @returns {*} 40 | */ 41 | function (next) { 42 | console.log(chalk.yellow('checking package dependencies...\n')); 43 | 44 | exec('dependency-check ./package.json --extra --no-dev --missing', next); 45 | }, 46 | 47 | /** 48 | * Runs system tests on SPEC_SOURCE_DIR using Mocha. 49 | * 50 | * @param {Function} next - The callback invoked to mark the completion of the test run. 51 | * @returns {*} 52 | */ 53 | function (next) { 54 | console.info('\nrunning system specs using mocha...'); 55 | 56 | var mocha = new Mocha(); 57 | 58 | recursive(SPEC_SOURCE_DIR, function (err, files) { 59 | if (err) { 60 | console.error(err); 61 | return exit(1); 62 | } 63 | 64 | files.filter(function (file) { 65 | return (file.substr(-8) === '.test.js'); 66 | }).forEach(function (file) { 67 | mocha.addFile(file); 68 | }); 69 | 70 | // start the mocha run 71 | mocha.run(next); 72 | mocha = null; // cleanup 73 | }); 74 | }, 75 | 76 | /** 77 | * Execute nsp checks on project dependencies. In-program usage of nsp is a bit tricky as we have to emulate the 78 | * cli script's usage of internal nsp functions. 79 | * 80 | * @param {Function} next - The callback function invoked upon completion of the NSP check. 81 | * @returns {*} 82 | */ 83 | function (next) { 84 | var nsp = require('nsp'), 85 | pkg = loadJSON('../package.json'), 86 | nsprc = loadJSON('../.nsprc'); 87 | 88 | console.info('processing nsp for security vulnerabilities...\n'); 89 | 90 | // we do not pass full package for privacy concerns and also to add the ability to ignore exclude packages, 91 | // hence we customise the package before we send it 92 | nsp.check({ 93 | offline: false, 94 | package: _.merge({ 95 | dependencies: _.omit(pkg.dependencies, nsprc.exclusions || []) 96 | }, _.pick(pkg, ['name', 'version', 'homepage', 'repository'])) 97 | }, function (err, result) { 98 | // if processing nsp had an error, simply print that and exit 99 | if (err) { 100 | console.error(chalk.red('There was an error processing NSP!\n') + chalk.gray(err.message || err) + 101 | '\n\nSince NSP server failure is not a blocker for tests, tests are not marked as failure!'); 102 | return next(); 103 | } 104 | 105 | // in case an nsp violation is found, we raise an error 106 | if (result.length) { 107 | console.error(nsp.formatters.default(err, result)); 108 | return next(1); 109 | } 110 | 111 | console.info(chalk.green('nsp ok!\n')); 112 | return next(); 113 | }); 114 | } 115 | ], exit); 116 | }; 117 | 118 | // ensure we run this script exports if this is a direct stdin.tty run 119 | !module.parent && module.exports(exit); 120 | -------------------------------------------------------------------------------- /test/unit/convert.test.js: -------------------------------------------------------------------------------- 1 | var expect = require('chai').expect, 2 | sdk = require('postman-collection'), 3 | exec = require('shelljs').exec, 4 | newman = require('newman'), 5 | parallel = require('async').parallel, 6 | 7 | convert = require('../../index').convert, 8 | mainCollection = require('./fixtures/testcollection/collection.json'); 9 | 10 | /** 11 | * runs codesnippet then compare it with newman output 12 | * 13 | * @param {String} codeSnippet - code snippet that needed to run using java 14 | * @param {Object} collection - collection which will be run using newman 15 | * @param {Function} done - callback for async calls 16 | */ 17 | function runSnippet (codeSnippet, collection, done) { 18 | 19 | // step by step process for compile, run code snippet, then comparing its output with newman 20 | parallel([ 21 | function (callback) { 22 | return exec(codeSnippet, function (err, stdout, stderr) { 23 | if (err) { 24 | return callback(err); 25 | } 26 | if (stderr) { 27 | return callback(stderr); 28 | } 29 | try { 30 | stdout = JSON.parse(stdout); 31 | } 32 | catch (e) { 33 | console.error(e); 34 | } 35 | return callback(null, stdout); 36 | }); 37 | }, 38 | function (callback) { 39 | newman.run({ 40 | collection: collection 41 | }).on('request', function (err, summary) { 42 | if (err) { 43 | return callback(err); 44 | } 45 | 46 | var stdout = summary.response.stream.toString(); 47 | if (summary.request.method === 'HEAD') { 48 | stdout = summary.response.code.toString(); 49 | return callback(null, stdout); 50 | } 51 | try { 52 | stdout = JSON.parse(stdout); 53 | } 54 | catch (e) { 55 | console.error(e); 56 | } 57 | return callback(null, stdout); 58 | }); 59 | } 60 | ], function (err, result) { 61 | if (err) { 62 | expect.fail(null, null, err); 63 | } 64 | else if (typeof result[1] !== 'object' || typeof result[0] !== 'object') { 65 | expect(result[0].trim()).to.include(result[1].trim()); 66 | } 67 | else { 68 | const propertiesTodelete = ['cookies', 'headersSize', 'startedDateTime', 'clientIPAddress'], 69 | headersTodelete = [ 70 | 'accept-encoding', 71 | 'user-agent', 72 | 'cf-ray', 73 | 'x-real-ip', 74 | 'x-request-id', 75 | 'kong-request-id', 76 | 'x-request-start', 77 | 'connect-time', 78 | 'x-forwarded-for', 79 | 'content-type', 80 | 'content-length', 81 | 'kong-cloud-request-id', 82 | 'accept', 83 | 'total-route-time', 84 | 'cookie' 85 | ]; 86 | if (result[0]) { 87 | propertiesTodelete.forEach(function (property) { 88 | delete result[0][property]; 89 | }); 90 | if (result[0].headers) { 91 | headersTodelete.forEach(function (property) { 92 | delete result[0].headers[property]; 93 | }); 94 | } 95 | } 96 | if (result[1]) { 97 | propertiesTodelete.forEach(function (property) { 98 | delete result[1][property]; 99 | }); 100 | if (result[1].headers) { 101 | headersTodelete.forEach(function (property) { 102 | delete result[1].headers[property]; 103 | }); 104 | } 105 | } 106 | 107 | expect(result[0]).deep.equal(result[1]); 108 | } 109 | return done(); 110 | }); 111 | } 112 | 113 | describe('curl convert function', function () { 114 | describe('convert for different request types', function () { 115 | 116 | mainCollection.item.forEach(function (item) { 117 | it(item.name, function (done) { 118 | var request = new sdk.Request(item.request), 119 | collection = { 120 | item: [ 121 | { 122 | request: request.toJSON() 123 | } 124 | ] 125 | }, 126 | options = { 127 | indentCount: 3, 128 | indentType: 'space', 129 | requestTimeout: 200, 130 | multiLine: true, 131 | followRedirect: true, 132 | longFormat: true, 133 | silent: true 134 | }; 135 | convert(request, options, function (error, snippet) { 136 | if (error) { 137 | expect.fail(null, null, error); 138 | return; 139 | } 140 | runSnippet(snippet, collection, done); 141 | }); 142 | }); 143 | }); 144 | }); 145 | }); 146 | -------------------------------------------------------------------------------- /test/system/repository.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileOverview This test specs runs tests on the package.json file of repository. It has a set of strict tests on the 3 | * content of the file as well. Any change to package.json must be accompanied by valid test case in this spec-sheet. 4 | */ 5 | var _ = require('lodash'), 6 | expect = require('chai').expect, 7 | parseIgnore = require('parse-gitignore'); 8 | 9 | /* global describe, it */ 10 | describe('project repository', function () { 11 | var fs = require('fs'); 12 | 13 | describe('package.json', function () { 14 | var content, 15 | json; 16 | 17 | try { 18 | content = fs.readFileSync('./package.json').toString(); 19 | json = JSON.parse(content); 20 | } 21 | catch (e) { 22 | console.error(e); 23 | content = ''; 24 | json = {}; 25 | } 26 | 27 | it('must have readable JSON content', function () { 28 | expect(content).to.be.ok; 29 | expect(json).to.not.eql({}); 30 | }); 31 | 32 | describe('package.json JSON data', function () { 33 | it('must have valid name, description and author', function () { 34 | expect(json).to.have.property('name', '@postman/codegen-curl'); 35 | expect(json).to.have.property('author', 'Postman Labs '); 36 | expect(json).to.have.property('license', 'Apache-2.0'); 37 | 38 | expect(json).to.have.property('repository'); 39 | expect(json.repository).to.eql({ 40 | type: 'git', 41 | url: 'git@bitbucket.org:postmanlabs/codegen-curl.git' 42 | }); 43 | 44 | expect(json).to.have.property('engines'); 45 | expect(json.engines).to.eql({ node: '>=4' }); 46 | }); 47 | 48 | it('must have a valid version string in form of ..', function () { 49 | // eslint-disable-next-line max-len 50 | expect(json.version).to.match(/^((\d+)\.(\d+)\.(\d+))(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/); 51 | }); 52 | }); 53 | 54 | describe('script definitions', function () { 55 | it('files must exist', function () { 56 | var scriptRegex = /^node\snpm\/.+\.js$/; 57 | 58 | expect(json.scripts).to.be.ok; 59 | json.scripts && Object.keys(json.scripts).forEach(function (scriptName) { 60 | expect(scriptRegex.test(json.scripts[scriptName])).to.be.ok; 61 | expect(fs.statSync('npm/' + scriptName + '.js')).to.be.ok; 62 | }); 63 | }); 64 | 65 | it('must have the hashbang defined', function () { 66 | json.scripts && Object.keys(json.scripts).forEach(function (scriptName) { 67 | var fileContent = fs.readFileSync('npm/' + scriptName + '.js').toString(); 68 | expect(/^#!\/(bin\/bash|usr\/bin\/env\snode)[\r\n][\W\w]*$/g.test(fileContent)).to.be.ok; 69 | }); 70 | }); 71 | }); 72 | 73 | describe.skip('dependencies', function () { 74 | it('must exist', function () { 75 | expect(json.dependencies).to.be.a('object'); 76 | }); 77 | 78 | it('must point to a valid and precise (no * or ^) semver', function () { 79 | json.dependencies && Object.keys(json.dependencies).forEach(function (item) { 80 | expect(json.dependencies[item]).to.match(new RegExp('^((\\d+)\\.(\\d+)\\.(\\d+))(?:-' + 81 | '([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?(?:\\+([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?$')); 82 | }); 83 | }); 84 | }); 85 | 86 | describe('devDependencies', function () { 87 | it('must exist', function () { 88 | expect(json.devDependencies).to.be.a('object'); 89 | }); 90 | 91 | it('must point to a valid and precise (no * or ^) semver', function () { 92 | json.devDependencies && Object.keys(json.devDependencies).forEach(function (item) { 93 | expect(json.devDependencies[item]).to.match(new RegExp('^((\\d+)\\.(\\d+)\\.(\\d+))(?:-' + 94 | '([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?(?:\\+([\\dA-Za-z\\-]+(?:\\.[\\dA-Za-z\\-]+)*))?$')); 95 | }); 96 | }); 97 | 98 | it.skip('should not overlap dependencies', function () { 99 | var clean = []; 100 | 101 | json.devDependencies && Object.keys(json.devDependencies).forEach(function (item) { 102 | !json.dependencies[item] && clean.push(item); 103 | }); 104 | 105 | expect(Object.keys(json.devDependencies)).to.eql(clean); 106 | }); 107 | }); 108 | 109 | describe('main entry script', function () { 110 | it('must point to a valid file', function (done) { 111 | expect(json.main).to.equal('index.js'); 112 | fs.stat(json.main, done); 113 | }); 114 | }); 115 | }); 116 | 117 | describe('README.md', function () { 118 | it('must exist', function (done) { 119 | fs.stat('./README.md', done); 120 | }); 121 | 122 | it('must have readable content', function () { 123 | expect(fs.readFileSync('./README.md').toString()).to.be.ok; 124 | }); 125 | }); 126 | 127 | describe('LICENSE.md.md', function () { 128 | it('must exist', function (done) { 129 | fs.stat('./LICENSE.md', done); 130 | }); 131 | 132 | it('must have readable content', function () { 133 | expect(fs.readFileSync('./LICENSE.md').toString()).to.be.ok; 134 | }); 135 | }); 136 | 137 | describe('.ignore files', function () { 138 | var gitignorePath = '.gitignore', 139 | npmignorePath = '.npmignore', 140 | npmignore = parseIgnore(npmignorePath), 141 | gitignore = parseIgnore(gitignorePath); 142 | 143 | describe(gitignorePath, function () { 144 | it('must exist', function (done) { 145 | fs.stat(gitignorePath, done); 146 | }); 147 | 148 | it('must have valid content', function () { 149 | expect(_.isEmpty(gitignore)).to.not.be.ok; 150 | }); 151 | }); 152 | 153 | describe(npmignorePath, function () { 154 | it('must exist', function (done) { 155 | fs.stat(npmignorePath, done); 156 | }); 157 | 158 | it('must have valid content', function () { 159 | expect(_.isEmpty(npmignore)).to.not.be.ok; 160 | }); 161 | }); 162 | 163 | it('.gitignore coverage must be a subset of .npmignore coverage', function () { 164 | expect(_.intersection(gitignore, npmignore)).to.eql(gitignore); 165 | }); 166 | }); 167 | 168 | describe('.eslintrc', function () { 169 | it('must exist', function (done) { 170 | fs.stat('./.eslintrc', done); 171 | }); 172 | 173 | it('must have readable content', function () { 174 | expect(fs.readFileSync('./.eslintrc').toString()).to.be.ok; 175 | }); 176 | }); 177 | 178 | describe('.nsprc', function () { 179 | it('must exist', function (done) { 180 | fs.stat('./.nsprc', done); 181 | }); 182 | 183 | it('must have readable content', function () { 184 | expect(fs.readFileSync('./.nsprc').toString()).to.be.ok; 185 | }); 186 | }); 187 | }); 188 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Postdot Technologies Pvt. Ltd. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "jsdoc", 4 | "security", 5 | "lodash" 6 | ], 7 | "env": { 8 | "node": true, 9 | "es6": true 10 | }, 11 | "rules": { 12 | // Possible Errors 13 | "for-direction": "error", 14 | "getter-return": "error", 15 | "no-await-in-loop": "error", 16 | "no-compare-neg-zero": "error", 17 | "no-cond-assign": "error", 18 | "no-console": "off", 19 | "no-constant-condition": "error", 20 | "no-control-regex": "error", 21 | "no-debugger": "error", 22 | "no-dupe-args": "error", 23 | "no-dupe-keys": "error", 24 | "no-duplicate-case": "error", 25 | "no-empty": "error", 26 | "no-empty-character-class": "error", 27 | "no-ex-assign": "error", 28 | "no-extra-boolean-cast": "error", 29 | "no-extra-parens": "off", 30 | "no-extra-semi": "error", 31 | "no-func-assign": "error", 32 | "no-inner-declarations": "off", 33 | "no-invalid-regexp": "error", 34 | "no-irregular-whitespace": "error", 35 | "no-obj-calls": "error", 36 | "no-prototype-builtins": "off", 37 | "no-regex-spaces": "error", 38 | "no-sparse-arrays": "error", 39 | "no-template-curly-in-string": "error", 40 | "no-unexpected-multiline": "error", 41 | "no-unreachable": "error", 42 | "no-unsafe-finally": "error", 43 | "no-unsafe-negation": "error", 44 | "use-isnan": "error", 45 | "valid-jsdoc": "off", 46 | "valid-typeof": "error", 47 | 48 | // Best Practices 49 | "accessor-pairs": "error", 50 | "array-callback-return": "off", 51 | "block-scoped-var": "error", 52 | "class-methods-use-this": "error", 53 | "complexity": "off", 54 | "consistent-return": "warn", 55 | "curly": "error", 56 | "default-case": "error", 57 | "dot-location": ["error", "property"], 58 | "dot-notation": "error", 59 | "eqeqeq": "error", 60 | "guard-for-in": "warn", 61 | "no-alert": "error", 62 | "no-caller": "error", 63 | "no-case-declarations": "error", 64 | "no-div-regex": "error", 65 | "no-else-return": "error", 66 | "no-empty-function": "error", 67 | "no-empty-pattern": "error", 68 | "no-eq-null": "error", 69 | "no-eval": "error", 70 | "no-extend-native": "error", 71 | "no-extra-bind": "error", 72 | "no-extra-label": "error", 73 | "no-fallthrough": "error", 74 | "no-floating-decimal": "error", 75 | "no-global-assign": "error", 76 | "no-implicit-coercion": "error", 77 | "no-implicit-globals": "error", 78 | "no-implied-eval": "error", 79 | "no-invalid-this": "error", 80 | "no-iterator": "error", 81 | "no-labels": "error", 82 | "no-lone-blocks": "error", 83 | "no-loop-func": "error", 84 | "no-magic-numbers": "off", 85 | "no-multi-spaces": "error", 86 | "no-multi-str": "error", 87 | "no-new": "error", 88 | "no-new-func": "error", 89 | "no-new-wrappers": "error", 90 | "no-octal": "error", 91 | "no-octal-escape": "error", 92 | "no-param-reassign": "off", 93 | "no-proto": "error", 94 | "no-redeclare": "error", 95 | "no-restricted-properties": "error", 96 | "no-return-assign": "error", 97 | "no-return-await": "error", 98 | "no-script-url": "error", 99 | "no-self-assign": "error", 100 | "no-self-compare": "error", 101 | "no-sequences": "error", 102 | "no-throw-literal": "error", 103 | "no-unmodified-loop-condition": "error", 104 | "no-unused-expressions": "off", 105 | "no-unused-labels": "error", 106 | "no-useless-call": "error", 107 | "no-useless-concat": "error", 108 | "no-useless-escape": "error", 109 | "no-useless-return": "error", 110 | "no-void": "error", 111 | "no-warning-comments": "off", 112 | "no-with": "error", 113 | "prefer-promise-reject-errors": "error", 114 | "radix": "off", 115 | "require-await": "error", 116 | "vars-on-top": "off", 117 | "wrap-iife": "error", 118 | "yoda": "error", 119 | 120 | // Strict Mode 121 | "strict": "off", 122 | 123 | // Variables 124 | "init-declarations": "off", 125 | "no-catch-shadow": "error", 126 | "no-delete-var": "error", 127 | "no-label-var": "error", 128 | "no-restricted-globals": "error", 129 | "no-shadow": "off", 130 | "no-shadow-restricted-names": "error", 131 | "no-undef": "off", 132 | "no-undef-init": "error", 133 | "no-undefined": "off", 134 | "no-unused-vars": "error", 135 | "no-use-before-define": "error", 136 | 137 | // Node.js and CommonJS 138 | "callback-return": "error", 139 | "global-require": "off", 140 | "handle-callback-err": "error", 141 | "no-buffer-constructor": "error", 142 | "no-mixed-requires": "off", 143 | "no-new-require": "off", 144 | "no-path-concat": "error", 145 | "no-process-env": "error", 146 | "no-process-exit": "off", 147 | "no-restricted-modules": "error", 148 | "no-sync": "off", 149 | 150 | // Stylistic Issues 151 | "array-bracket-newline": "off", 152 | "array-bracket-spacing": "off", 153 | "array-element-newline": "off", 154 | "block-spacing": "error", 155 | "brace-style": [2, "stroustrup", { "allowSingleLine": true }], 156 | "camelcase": "off", 157 | "capitalized-comments": "off", 158 | "comma-dangle": ["error", "never"], 159 | "comma-spacing": [2, { "before": false, "after": true }], 160 | "comma-style": ["error", "last"], 161 | "computed-property-spacing": "error", 162 | "consistent-this": "off", 163 | "eol-last": "error", 164 | "func-call-spacing": "error", 165 | "func-name-matching": "off", 166 | "func-names": "off", 167 | "func-style": "off", 168 | "id-blacklist": "error", 169 | "id-length": "off", 170 | "id-match": "error", 171 | "indent": ["error", 4, { 172 | "VariableDeclarator": { "var": 1, "let": 1, "const": 1 }, 173 | "SwitchCase": 1 174 | }], 175 | "jsx-quotes": ["error", "prefer-single"], 176 | "key-spacing": "error", 177 | "keyword-spacing": "error", 178 | "line-comment-position": "off", 179 | "linebreak-style": ["error", "unix"], 180 | "lines-around-comment": ["error", { 181 | "beforeBlockComment": true, 182 | "afterBlockComment": false, 183 | "beforeLineComment": false, 184 | "afterLineComment": false, 185 | "allowBlockStart": true, 186 | "allowBlockEnd": false, 187 | "allowObjectStart": true, 188 | "allowObjectEnd": false, 189 | "allowArrayStart": true, 190 | "allowArrayEnd": false 191 | }], 192 | "max-depth": "error", 193 | "max-len": ["error", { 194 | "code": 120 195 | }], 196 | "max-lines": "off", 197 | "max-nested-callbacks": "error", 198 | "max-params": "off", 199 | "max-statements": "off", 200 | "max-statements-per-line": "off", 201 | "multiline-ternary": "off", 202 | "new-cap": "off", 203 | "new-parens": "error", 204 | "newline-per-chained-call": "off", 205 | "no-array-constructor": "error", 206 | "no-bitwise": "off", 207 | "no-continue": "off", 208 | "no-inline-comments": "off", 209 | "no-lonely-if": "error", 210 | "no-mixed-operators": "off", 211 | "no-mixed-spaces-and-tabs": "error", 212 | "no-multi-assign": "off", 213 | "no-multiple-empty-lines": "error", 214 | "no-negated-condition": "off", 215 | "no-nested-ternary": "off", 216 | "no-new-object": "error", 217 | "no-plusplus": "off", 218 | "no-restricted-syntax": "error", 219 | "no-tabs": "error", 220 | "no-ternary": "off", 221 | "no-trailing-spaces": "error", 222 | "no-underscore-dangle": "off", 223 | "no-unneeded-ternary": "error", 224 | "no-whitespace-before-property": "error", 225 | "nonblock-statement-body-position": "error", 226 | "object-curly-newline": "off", 227 | "object-curly-spacing": "off", 228 | "object-property-newline": "off", 229 | "one-var": ["error", "always"], 230 | "one-var-declaration-per-line": "error", 231 | "operator-assignment": "error", 232 | "operator-linebreak": ["error", "after"], 233 | "padded-blocks": "off", 234 | "padding-line-between-statements": "off", 235 | "quote-props": "off", 236 | "quotes": ["error", "single"], 237 | "require-jsdoc": "warn", 238 | "semi": "error", 239 | "semi-spacing": "error", 240 | "sort-keys": "off", 241 | "sort-vars": "off", 242 | "space-before-blocks": "error", 243 | "space-before-function-paren": "error", 244 | "space-in-parens": "error", 245 | "space-infix-ops": "error", 246 | "space-unary-ops": "error", 247 | "spaced-comment": ["error", "always", { 248 | "block": { 249 | "exceptions": ["!"] 250 | } 251 | }], 252 | "switch-colon-spacing": "error", 253 | "template-tag-spacing": "error", 254 | "unicode-bom": "error", 255 | "wrap-regex": "error", 256 | 257 | // ECMAScript 6 258 | "arrow-body-style": ["error", "always"], 259 | "arrow-parens": ["error", "always"], 260 | "arrow-spacing": "error", 261 | "constructor-super": "error", 262 | "generator-star-spacing": "error", 263 | "no-class-assign": "error", 264 | "no-confusing-arrow": "error", 265 | "no-const-assign": "error", 266 | "no-dupe-class-members": "error", 267 | "no-duplicate-imports": "error", 268 | "no-new-symbol": "error", 269 | "no-restricted-imports": "error", 270 | "no-this-before-super": "error", 271 | "no-useless-computed-key": "error", 272 | "no-useless-constructor": "off", 273 | "no-var": "off", 274 | "object-shorthand": "off", 275 | "prefer-arrow-callback": "off", 276 | "prefer-const": "off", 277 | "prefer-destructuring": "off", 278 | "prefer-numeric-literals": "off", 279 | "prefer-rest-params": "off", 280 | "prefer-spread": "error", 281 | "prefer-template": "off", 282 | "require-yield": "error", 283 | "rest-spread-spacing": "error", 284 | "sort-imports": "off", 285 | "symbol-description": "off", 286 | "template-curly-spacing": "error", 287 | "yield-star-spacing": "error", 288 | 289 | // Lodash 290 | "lodash/callback-binding": "error", 291 | "lodash/collection-method-value": "warn", 292 | "lodash/collection-return": "error", 293 | "lodash/no-double-unwrap": "error", 294 | "lodash/no-extra-args": "error", 295 | "lodash/no-unbound-this": "error", 296 | "lodash/unwrap": "error", 297 | 298 | "lodash/chain-style": ["error", "as-needed"], 299 | "lodash/chaining": ["error", "always", 3], 300 | "lodash/consistent-compose": ["error", "flow"], 301 | "lodash/identity-shorthand": ["error", "always"], 302 | "lodash/import-scope": "off", 303 | "lodash/matches-prop-shorthand": ["error", "always"], 304 | "lodash/matches-shorthand": ["error", "always", 3], 305 | "lodash/no-commit": "error", 306 | "lodash/path-style": ["error", "as-needed"], 307 | "lodash/prefer-compact": "error", 308 | "lodash/prefer-filter": ["off", 3], 309 | "lodash/prefer-flat-map": "error", 310 | "lodash/prefer-invoke-map": "error", 311 | "lodash/prefer-map": "error", 312 | "lodash/prefer-reject": ["error", 3], 313 | "lodash/prefer-thru": "error", 314 | "lodash/prefer-wrapper-method": "error", 315 | "lodash/preferred-alias": "off", 316 | "lodash/prop-shorthand": ["error", "always"], 317 | 318 | "lodash/prefer-constant": "off", 319 | "lodash/prefer-get": ["warn", 4], 320 | "lodash/prefer-includes": ["error", { "includeNative": true }], 321 | "lodash/prefer-is-nil": "error", 322 | "lodash/prefer-lodash-chain": "error", 323 | "lodash/prefer-lodash-method": "off", 324 | "lodash/prefer-lodash-typecheck": "off", 325 | "lodash/prefer-matches": ["off", 3], 326 | "lodash/prefer-noop": "off", 327 | "lodash/prefer-over-quantifier": "warn", 328 | "lodash/prefer-some": "off", 329 | "lodash/prefer-startswith": "off", 330 | "lodash/prefer-times": "off", 331 | 332 | // JsDoc 333 | "jsdoc/check-param-names": "error", 334 | "jsdoc/check-tag-names": "off", 335 | "jsdoc/check-types": "off", 336 | "jsdoc/newline-after-description": "error", 337 | "jsdoc/require-description-complete-sentence": "off", 338 | "jsdoc/require-example": "off", 339 | "jsdoc/require-hyphen-before-param-description": "off", 340 | "jsdoc/require-param": "error", 341 | "jsdoc/require-param-description": "off", 342 | "jsdoc/require-param-type": "off", 343 | "jsdoc/require-returns-description": "off", 344 | "jsdoc/require-returns-type": "error", 345 | 346 | // Security 347 | "security/detect-unsafe-regex": "off", 348 | "security/detect-buffer-noassert": "error", 349 | "security/detect-child-process": "error", 350 | "security/detect-disable-mustache-escape": "error", 351 | "security/detect-eval-with-expression": "error", 352 | "security/detect-no-csrf-before-method-override": "off", 353 | "security/detect-non-literal-fs-filename": "off", 354 | "security/detect-non-literal-regexp": "warn", 355 | "security/detect-non-literal-require": "off", 356 | "security/detect-object-injection": "off", 357 | "security/detect-possible-timing-attacks": "error", 358 | "security/detect-pseudoRandomBytes": "error" 359 | } 360 | } 361 | -------------------------------------------------------------------------------- /test/unit/fixtures/testcollection/collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "name": "Code-Gen Test Cases", 4 | "_postman_id": "41182fad-912e-6bc9-d6b9-dfb6f5bf5ffb", 5 | "description": "This collection contains requests that will be used to test validity of plugin created to convert postman request into code snippet of particular language.", 6 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 7 | }, 8 | "item": [ 9 | { 10 | "name": "Request Headers with disabled headers", 11 | "event": [ 12 | { 13 | "listen": "test", 14 | "script": { 15 | "type": "text/javascript", 16 | "exec": [ 17 | "var responseJSON;", 18 | "try {", 19 | " tests[\"Body contains headers\"] = responseBody.has(\"headers\");", 20 | " responseJSON = JSON.parse(responseBody);", 21 | " tests[\"Header contains host\"] = \"host\" in responseJSON.headers;", 22 | " tests[\"Header contains test parameter sent as part of request header\"] = \"my-sample-header\" in responseJSON.headers;", 23 | "}", 24 | "catch (e) { }", 25 | "", 26 | "", 27 | "", 28 | "" 29 | ] 30 | } 31 | } 32 | ], 33 | "request": { 34 | "method": "GET", 35 | "header": [ 36 | { 37 | "key": "my-sample-header", 38 | "value": "Lorem ipsum dolor sit amet" 39 | }, 40 | { 41 | "key": "not-disabled-header", 42 | "value": "ENABLED" 43 | }, 44 | { 45 | "key": "disabled header", 46 | "value": "DISABLED", 47 | "disabled": true 48 | } 49 | ], 50 | "body": {}, 51 | "url": { 52 | "raw": "https://postman-echo.com/headers", 53 | "protocol": "https", 54 | "host": [ 55 | "postman-echo", 56 | "com" 57 | ], 58 | "path": [ 59 | "headers" 60 | ] 61 | }, 62 | "description": "A `GET` request to this endpoint returns the list of all request headers as part of the response JSON.\nIn Postman, sending your own set of headers through the [Headers tab](https://www.getpostman.com/docs/requests#headers?source=echo-collection-app-onboarding) will reveal the headers as part of the response." 63 | }, 64 | "response": [] 65 | }, 66 | { 67 | "name": "GET Request with disabled query", 68 | "event": [ 69 | { 70 | "listen": "test", 71 | "script": { 72 | "type": "text/javascript", 73 | "exec": [ 74 | "var responseJSON;", 75 | "", 76 | "try { ", 77 | " responseJSON = JSON.parse(responseBody); ", 78 | " tests['response is valid JSON'] = true;", 79 | "}", 80 | "catch (e) { ", 81 | " responseJSON = {}; ", 82 | " tests['response is valid JSON'] = false;", 83 | "}", 84 | "", 85 | "tests['response json contains headers'] = _.has(responseJSON, 'headers');", 86 | "tests['response json contains args'] = _.has(responseJSON, 'args');", 87 | "tests['response json contains url'] = _.has(responseJSON, 'url');", 88 | "", 89 | "tests['args key contains argument passed as url parameter'] = ('test' in responseJSON.args);", 90 | "tests['args passed via request url params has value \"123\"'] = (_.get(responseJSON, 'args.test') === \"123\");" 91 | ] 92 | } 93 | } 94 | ], 95 | "request": { 96 | "method": "GET", 97 | "header": [], 98 | "body": {}, 99 | "url": { 100 | "raw": "https://postman-echo.com/get?test=123&anotherone=232", 101 | "protocol": "https", 102 | "host": [ 103 | "postman-echo", 104 | "com" 105 | ], 106 | "path": [ 107 | "get" 108 | ], 109 | "query": [ 110 | { 111 | "key": "test", 112 | "value": "123", 113 | "equals": true 114 | }, 115 | { 116 | "key": "anotherone", 117 | "value": "232", 118 | "equals": true 119 | }, 120 | { 121 | "key": "anotheroneone", 122 | "value": "sdfsdf", 123 | "equals": true, 124 | "disabled": true 125 | } 126 | ] 127 | }, 128 | "description": "The HTTP `GET` request method is meant to retrieve data from a server. The data\nis identified by a unique URI (Uniform Resource Identifier). \n\nA `GET` request can pass parameters to the server using \"Query String \nParameters\". For example, in the following request,\n\n> http://example.com/hi/there?hand=wave\n\nThe parameter \"hand\" has the value \"wave\".\n\nThis endpoint echoes the HTTP headers, request parameters and the complete\nURI requested." 129 | }, 130 | "response": [] 131 | }, 132 | { 133 | "name": "POST Raw Text", 134 | "event": [ 135 | { 136 | "listen": "test", 137 | "script": { 138 | "id": "753f8a33-adb6-402f-8d19-386c1981ecb6", 139 | "type": "text/javascript", 140 | "exec": [ 141 | "var responseJSON;", 142 | "", 143 | "try { ", 144 | " responseJSON = JSON.parse(responseBody); ", 145 | " tests['response is valid JSON'] = true;", 146 | "}", 147 | "catch (e) { ", 148 | " responseJSON = {}; ", 149 | " tests['response is valid JSON'] = false;", 150 | "}", 151 | "", 152 | "", 153 | "tests['response has post data'] = _.has(responseJSON, 'data');", 154 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 155 | "", 156 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 157 | ] 158 | } 159 | } 160 | ], 161 | "request": { 162 | "method": "POST", 163 | "header": [ 164 | { 165 | "key": "Content-Type", 166 | "value": "text/plain" 167 | } 168 | ], 169 | "body": { 170 | "mode": "raw", 171 | "raw": "\"'Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium. Praesent neque quam, tincidunt nec leo eget, rutrum vehicula magna.\nMaecenas consequat elementum elit, \"id\" \"se\\\"mper\" sem tristique et. Integer pulvinar enim quis consectetur interdum volutpat.'\"" 172 | }, 173 | "url": { 174 | "raw": "https://postman-echo.com/post", 175 | "protocol": "https", 176 | "host": [ 177 | "postman-echo", 178 | "com" 179 | ], 180 | "path": [ 181 | "post" 182 | ] 183 | }, 184 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 185 | }, 186 | "response": [] 187 | }, 188 | { 189 | "name": "POST form data with file", 190 | "event": [ 191 | { 192 | "listen": "test", 193 | "script": { 194 | "type": "text/javascript", 195 | "exec": [ 196 | "var responseJSON;", 197 | "", 198 | "try { ", 199 | " responseJSON = JSON.parse(responseBody); ", 200 | " tests['response is valid JSON'] = true;", 201 | "}", 202 | "catch (e) { ", 203 | " responseJSON = {}; ", 204 | " tests['response is valid JSON'] = false;", 205 | "}", 206 | "", 207 | "", 208 | "tests['response has post data'] = _.has(responseJSON, 'data');", 209 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 210 | "", 211 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 212 | ] 213 | } 214 | } 215 | ], 216 | "request": { 217 | "method": "POST", 218 | "header": [ 219 | { 220 | "key": "Content-Type", 221 | "value": "application/x-www-form-urlencoded", 222 | "disabled": true 223 | }, 224 | { 225 | "key": "content-type", 226 | "value": "application/json", 227 | "disabled": true 228 | } 229 | ], 230 | "body": { 231 | "mode": "formdata", 232 | "formdata": [ 233 | { 234 | "key": "fdjks", 235 | "value": "dsf", 236 | "type": "text" 237 | }, 238 | { 239 | "key": "&^%", 240 | "value": "helo", 241 | "type": "text" 242 | }, 243 | { 244 | "key": "12", 245 | "value": "\"23\"", 246 | "description": "", 247 | "type": "text" 248 | }, 249 | { 250 | "key": "'123'", 251 | "value": "'\"23\\\"4\\\"\"'", 252 | "description": "", 253 | "type": "text" 254 | }, 255 | { 256 | "key": "", 257 | "value": "", 258 | "description": "", 259 | "type": "text", 260 | "disabled": true 261 | } 262 | ] 263 | }, 264 | "url": { 265 | "raw": "https://postman-echo.com/post", 266 | "protocol": "https", 267 | "host": [ 268 | "postman-echo", 269 | "com" 270 | ], 271 | "path": [ 272 | "post" 273 | ] 274 | }, 275 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 276 | }, 277 | "response": [] 278 | }, 279 | { 280 | "name": "POST urlencoded data with disabled entries", 281 | "event": [ 282 | { 283 | "listen": "test", 284 | "script": { 285 | "type": "text/javascript", 286 | "exec": [ 287 | "var responseJSON;", 288 | "", 289 | "try { ", 290 | " responseJSON = JSON.parse(responseBody); ", 291 | " tests['response is valid JSON'] = true;", 292 | "}", 293 | "catch (e) { ", 294 | " responseJSON = {}; ", 295 | " tests['response is valid JSON'] = false;", 296 | "}", 297 | "", 298 | "", 299 | "tests['response has post data'] = _.has(responseJSON, 'data');", 300 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 301 | "", 302 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 303 | ] 304 | } 305 | } 306 | ], 307 | "request": { 308 | "method": "POST", 309 | "header": [ 310 | { 311 | "key": "Content-Type", 312 | "value": "application/x-www-form-urlencoded" 313 | } 314 | ], 315 | "body": { 316 | "mode": "urlencoded", 317 | "urlencoded": [ 318 | { 319 | "key": "1", 320 | "value": "a", 321 | "description": "", 322 | "type": "text" 323 | }, 324 | { 325 | "key": "2", 326 | "value": "b", 327 | "description": "", 328 | "type": "text" 329 | }, 330 | { 331 | "key": "\"\"12\"\"", 332 | "value": "\"23\"", 333 | "description": "", 334 | "type": "text" 335 | }, 336 | { 337 | "key": "'1\"2\\\"\"3'", 338 | "value": "'1\"23\"4'", 339 | "description": "", 340 | "type": "text" 341 | } 342 | ] 343 | }, 344 | "url": { 345 | "raw": "https://postman-echo.com/post/?hardik=\"me\"", 346 | "protocol": "https", 347 | "host": [ 348 | "postman-echo", 349 | "com" 350 | ], 351 | "path": [ 352 | "post", 353 | "" 354 | ], 355 | "query": [ 356 | { 357 | "key": "hardik", 358 | "value": "\"me\"", 359 | "equals": true 360 | } 361 | ] 362 | }, 363 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 364 | }, 365 | "response": [] 366 | }, 367 | { 368 | "name": "POST json with raw", 369 | "event": [ 370 | { 371 | "listen": "test", 372 | "script": { 373 | "type": "text/javascript", 374 | "exec": [ 375 | "var responseJSON;", 376 | "", 377 | "try { ", 378 | " responseJSON = JSON.parse(responseBody); ", 379 | " tests['response is valid JSON'] = true;", 380 | "}", 381 | "catch (e) { ", 382 | " responseJSON = {}; ", 383 | " tests['response is valid JSON'] = false;", 384 | "}", 385 | "", 386 | "", 387 | "tests['response has post data'] = _.has(responseJSON, 'data');", 388 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 389 | "", 390 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 391 | ] 392 | } 393 | } 394 | ], 395 | "request": { 396 | "method": "POST", 397 | "header": [ 398 | { 399 | "key": "Content-Type", 400 | "value": "application/json" 401 | } 402 | ], 403 | "body": { 404 | "mode": "raw", 405 | "raw": "{\n \"json\": \"Test-Test\"\n}" 406 | }, 407 | "url": { 408 | "raw": "https://postman-echo.com/post", 409 | "protocol": "https", 410 | "host": [ 411 | "postman-echo", 412 | "com" 413 | ], 414 | "path": [ 415 | "post" 416 | ] 417 | }, 418 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 419 | }, 420 | "response": [ 421 | { 422 | "id": "db02f994-5ac4-41e1-835a-f49a14acbb6e", 423 | "name": "POST json with raw", 424 | "originalRequest": { 425 | "method": "POST", 426 | "header": [ 427 | { 428 | "key": "Content-Type", 429 | "value": "application/json" 430 | } 431 | ], 432 | "body": { 433 | "mode": "raw", 434 | "raw": "{\n \"json\": \"Test-Test\"\n}" 435 | }, 436 | "url": { 437 | "raw": "https://postman-echo.com/post", 438 | "protocol": "https", 439 | "host": [ 440 | "postman-echo", 441 | "com" 442 | ], 443 | "path": [ 444 | "post" 445 | ] 446 | } 447 | }, 448 | "status": "OK", 449 | "code": 200, 450 | "_postman_previewlanguage": "json", 451 | "header": [ 452 | { 453 | "key": "Access-Control-Allow-Credentials", 454 | "value": "", 455 | "name": "Access-Control-Allow-Credentials", 456 | "description": "Indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials." 457 | }, 458 | { 459 | "key": "Access-Control-Allow-Headers", 460 | "value": "", 461 | "name": "Access-Control-Allow-Headers", 462 | "description": "Used in response to a preflight request to indicate which HTTP headers can be used when making the actual request." 463 | }, 464 | { 465 | "key": "Access-Control-Allow-Methods", 466 | "value": "", 467 | "name": "Access-Control-Allow-Methods", 468 | "description": "Specifies the method or methods allowed when accessing the resource. This is used in response to a preflight request." 469 | }, 470 | { 471 | "key": "Access-Control-Allow-Origin", 472 | "value": "", 473 | "name": "Access-Control-Allow-Origin", 474 | "description": "Specifies a URI that may access the resource. For requests without credentials, the server may specify '*' as a wildcard, thereby allowing any origin to access the resource." 475 | }, 476 | { 477 | "key": "Access-Control-Expose-Headers", 478 | "value": "", 479 | "name": "Access-Control-Expose-Headers", 480 | "description": "Lets a server whitelist headers that browsers are allowed to access." 481 | }, 482 | { 483 | "key": "Connection", 484 | "value": "keep-alive", 485 | "name": "Connection", 486 | "description": "Options that are desired for the connection" 487 | }, 488 | { 489 | "key": "Content-Encoding", 490 | "value": "gzip", 491 | "name": "Content-Encoding", 492 | "description": "The type of encoding used on the data." 493 | }, 494 | { 495 | "key": "Content-Length", 496 | "value": "385", 497 | "name": "Content-Length", 498 | "description": "The length of the response body in octets (8-bit bytes)" 499 | }, 500 | { 501 | "key": "Content-Type", 502 | "value": "application/json; charset=utf-8", 503 | "name": "Content-Type", 504 | "description": "The mime type of this content" 505 | }, 506 | { 507 | "key": "Date", 508 | "value": "Wed, 07 Feb 2018 10:06:15 GMT", 509 | "name": "Date", 510 | "description": "The date and time that the message was sent" 511 | }, 512 | { 513 | "key": "ETag", 514 | "value": "W/\"215-u7EU1nFtauIn0/aVifjuXA\"", 515 | "name": "ETag", 516 | "description": "An identifier for a specific version of a resource, often a message digest" 517 | }, 518 | { 519 | "key": "Server", 520 | "value": "nginx", 521 | "name": "Server", 522 | "description": "A name for the server" 523 | }, 524 | { 525 | "key": "Vary", 526 | "value": "X-HTTP-Method-Override, Accept-Encoding", 527 | "name": "Vary", 528 | "description": "Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server." 529 | }, 530 | { 531 | "key": "set-cookie", 532 | "value": "sails.sid=s%3AxRBxgrc9M-jKK_l1mX3y3rM_ry8wYLz4.Of4qpOzd9hi6uO0sAQIj%2Bxs2VeppWxYjJa4OpIW3PKg; Path=/; HttpOnly", 533 | "name": "set-cookie", 534 | "description": "an HTTP cookie" 535 | } 536 | ], 537 | "cookie": [ 538 | { 539 | "expires": "Tue Jan 19 2038 08:44:07 GMT+0530 (IST)", 540 | "httpOnly": true, 541 | "domain": "postman-echo.com", 542 | "path": "/", 543 | "secure": false, 544 | "value": "s%3AxRBxgrc9M-jKK_l1mX3y3rM_ry8wYLz4.Of4qpOzd9hi6uO0sAQIj%2Bxs2VeppWxYjJa4OpIW3PKg", 545 | "key": "sails.sid" 546 | } 547 | ], 548 | "body": "{\"args\":{},\"data\":\"{\\n \\\"json\\\": \\\"Test-Test\\\"\\n}\",\"files\":{},\"form\":{},\"headers\":{\"host\":\"postman-echo.com\",\"content-length\":\"25\",\"accept\":\"*/*\",\"accept-encoding\":\"gzip, deflate\",\"cache-control\":\"no-cache\",\"content-type\":\"text/plain\",\"cookie\":\"sails.sid=s%3AkOgtF1XmXtVFx-Eg3S7-37BKKaMqMDPe.hnwldNwyvsaASUiRR0Y0vcowadkMXO4HMegTeVIPgqo\",\"postman-token\":\"2ced782f-a141-428e-8af6-04ce954a77d5\",\"user-agent\":\"PostmanRuntime/7.1.1\",\"x-forwarded-port\":\"443\",\"x-forwarded-proto\":\"https\"},\"json\":null,\"url\":\"https://postman-echo.com/post\"}" 549 | } 550 | ] 551 | }, 552 | { 553 | "name": "POST javascript with raw", 554 | "event": [ 555 | { 556 | "listen": "test", 557 | "script": { 558 | "type": "text/javascript", 559 | "exec": [ 560 | "var responseJSON;", 561 | "", 562 | "try { ", 563 | " responseJSON = JSON.parse(responseBody); ", 564 | " tests['response is valid JSON'] = true;", 565 | "}", 566 | "catch (e) { ", 567 | " responseJSON = {}; ", 568 | " tests['response is valid JSON'] = false;", 569 | "}", 570 | "", 571 | "", 572 | "tests['response has post data'] = _.has(responseJSON, 'data');", 573 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 574 | "", 575 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 576 | ] 577 | } 578 | } 579 | ], 580 | "request": { 581 | "method": "POST", 582 | "header": [ 583 | { 584 | "key": "Content-Type", 585 | "value": "application/javascript" 586 | } 587 | ], 588 | "body": { 589 | "mode": "raw", 590 | "raw": "var val = 6;\nconsole.log(val);" 591 | }, 592 | "url": { 593 | "raw": "https://postman-echo.com/post", 594 | "protocol": "https", 595 | "host": [ 596 | "postman-echo", 597 | "com" 598 | ], 599 | "path": [ 600 | "post" 601 | ] 602 | }, 603 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 604 | }, 605 | "response": [] 606 | }, 607 | { 608 | "name": "POST text/xml with raw", 609 | "event": [ 610 | { 611 | "listen": "test", 612 | "script": { 613 | "type": "text/javascript", 614 | "exec": [ 615 | "var responseJSON;", 616 | "", 617 | "try { ", 618 | " responseJSON = JSON.parse(responseBody); ", 619 | " tests['response is valid JSON'] = true;", 620 | "}", 621 | "catch (e) { ", 622 | " responseJSON = {}; ", 623 | " tests['response is valid JSON'] = false;", 624 | "}", 625 | "", 626 | "", 627 | "tests['response has post data'] = _.has(responseJSON, 'data');", 628 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 629 | "", 630 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 631 | ] 632 | } 633 | } 634 | ], 635 | "request": { 636 | "method": "POST", 637 | "header": [ 638 | { 639 | "key": "Content-Type", 640 | "value": "text/xml" 641 | } 642 | ], 643 | "body": { 644 | "mode": "raw", 645 | "raw": "\n Test Test\n" 646 | }, 647 | "url": { 648 | "raw": "https://postman-echo.com/post", 649 | "protocol": "https", 650 | "host": [ 651 | "postman-echo", 652 | "com" 653 | ], 654 | "path": [ 655 | "post" 656 | ] 657 | }, 658 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 659 | }, 660 | "response": [] 661 | }, 662 | { 663 | "name": "POST text/html with raw", 664 | "event": [ 665 | { 666 | "listen": "test", 667 | "script": { 668 | "type": "text/javascript", 669 | "exec": [ 670 | "var responseJSON;", 671 | "", 672 | "try { ", 673 | " responseJSON = JSON.parse(responseBody); ", 674 | " tests['response is valid JSON'] = true;", 675 | "}", 676 | "catch (e) { ", 677 | " responseJSON = {}; ", 678 | " tests['response is valid JSON'] = false;", 679 | "}", 680 | "", 681 | "", 682 | "tests['response has post data'] = _.has(responseJSON, 'data');", 683 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 684 | "", 685 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 686 | ] 687 | } 688 | } 689 | ], 690 | "request": { 691 | "method": "POST", 692 | "header": [ 693 | { 694 | "key": "Content-Type", 695 | "value": "text/html" 696 | } 697 | ], 698 | "body": { 699 | "mode": "raw", 700 | "raw": "\n Test Test\n" 701 | }, 702 | "url": { 703 | "raw": "https://postman-echo.com/post", 704 | "protocol": "https", 705 | "host": [ 706 | "postman-echo", 707 | "com" 708 | ], 709 | "path": [ 710 | "post" 711 | ] 712 | }, 713 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 714 | }, 715 | "response": [] 716 | }, 717 | { 718 | "name": "Resolve URL", 719 | "request": { 720 | "method": "POST", 721 | "header": [ 722 | { 723 | "key": "Content-Type", 724 | "value": "application/x-www-form-urlencoded" 725 | } 726 | ], 727 | "body": { 728 | "mode": "raw", 729 | "raw": "Duis posuere augue vel cursus pharetra. In luctus a ex nec pretium. Praesent neque quam, tincidunt nec leo eget, rutrum vehicula magna.\nMaecenas consequat elementum elit, id semper sem tristique et. Integer pulvinar enim quis consectetur interdum volutpat." 730 | }, 731 | "url": { 732 | "raw": "https://postman-echo.com/:action", 733 | "protocol": "https", 734 | "host": [ 735 | "postman-echo", 736 | "com" 737 | ], 738 | "path": [ 739 | ":action" 740 | ], 741 | "variable": [ 742 | { 743 | "key": "action", 744 | "value": "post" 745 | } 746 | ] 747 | }, 748 | "description": null 749 | }, 750 | "response": [] 751 | }, 752 | { 753 | "name": "PUT Request", 754 | "event": [ 755 | { 756 | "listen": "test", 757 | "script": { 758 | "type": "text/javascript", 759 | "exec": [ 760 | "var responseJSON;", 761 | "", 762 | "try { ", 763 | " responseJSON = JSON.parse(responseBody); ", 764 | " tests['response is valid JSON'] = true;", 765 | "}", 766 | "catch (e) { ", 767 | " responseJSON = {}; ", 768 | " tests['response is valid JSON'] = false;", 769 | "}", 770 | "", 771 | "", 772 | "tests['response has PUT data'] = _.has(responseJSON, 'data');", 773 | "tests['response matches the data sent in request'] = (responseJSON.data && responseJSON.data.length === 256);" 774 | ] 775 | } 776 | } 777 | ], 778 | "request": { 779 | "method": "PUT", 780 | "header": [ 781 | { 782 | "key": "Content-Type", 783 | "value": "text/plain" 784 | } 785 | ], 786 | "body": { 787 | "mode": "raw", 788 | "raw": "Etiam mi lacus, cursus vitae felis et, blandit pellentesque neque. Vestibulum eget nisi a tortor commodo dignissim.\nQuisque ipsum ligula, faucibus a felis a, commodo elementum nisl. Mauris vulputate sapien et tincidunt viverra. Donec vitae velit nec metus." 789 | }, 790 | "url": { 791 | "raw": "https://postman-echo.com/put", 792 | "protocol": "https", 793 | "host": [ 794 | "postman-echo", 795 | "com" 796 | ], 797 | "path": [ 798 | "put" 799 | ] 800 | }, 801 | "description": "The HTTP `PUT` request method is similar to HTTP `POST`. It too is meant to \ntransfer data to a server (and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `PUT` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following \nraw HTTP request,\n\n> PUT /hi/there?hand=wave\n>\n> \n\n\n" 802 | }, 803 | "response": [] 804 | }, 805 | { 806 | "name": "PATCH Request", 807 | "event": [ 808 | { 809 | "listen": "test", 810 | "script": { 811 | "type": "text/javascript", 812 | "exec": [ 813 | "var responseJSON;", 814 | "", 815 | "try { ", 816 | " responseJSON = JSON.parse(responseBody); ", 817 | " tests['response is valid JSON'] = true;", 818 | "}", 819 | "catch (e) { ", 820 | " responseJSON = {}; ", 821 | " tests['response is valid JSON'] = false;", 822 | "}", 823 | "", 824 | "", 825 | "tests['response has PUT data'] = _.has(responseJSON, 'data');", 826 | "tests['response matches the data sent in request'] = (responseJSON.data && responseJSON.data.length === 256);" 827 | ] 828 | } 829 | } 830 | ], 831 | "request": { 832 | "method": "PATCH", 833 | "header": [ 834 | { 835 | "key": "Content-Type", 836 | "value": "text/plain" 837 | } 838 | ], 839 | "body": { 840 | "mode": "raw", 841 | "raw": "Curabitur auctor, elit nec pulvinar porttitor, ex augue condimentum enim, eget suscipit urna felis quis neque.\nSuspendisse sit amet luctus massa, nec venenatis mi. Suspendisse tincidunt massa at nibh efficitur fringilla. Nam quis congue mi. Etiam volutpat." 842 | }, 843 | "url": { 844 | "raw": "https://postman-echo.com/patch", 845 | "protocol": "https", 846 | "host": [ 847 | "postman-echo", 848 | "com" 849 | ], 850 | "path": [ 851 | "patch" 852 | ] 853 | }, 854 | "description": "The HTTP `PATCH` method is used to update resources on a server. The exact\nuse of `PATCH` requests depends on the server in question. There are a number\nof server implementations which handle `PATCH` differently. Technically, \n`PATCH` supports both Query String parameters and a Request Body.\n\nThis endpoint accepts an HTTP `PATCH` request and provides debug information\nsuch as the HTTP headers, Query String arguments, and the Request Body." 855 | }, 856 | "response": [] 857 | }, 858 | { 859 | "name": "DELETE Request", 860 | "event": [ 861 | { 862 | "listen": "test", 863 | "script": { 864 | "type": "text/javascript", 865 | "exec": [ 866 | "var responseJSON;", 867 | "", 868 | "try { ", 869 | " responseJSON = JSON.parse(responseBody); ", 870 | " tests['response is valid JSON'] = true;", 871 | "}", 872 | "catch (e) { ", 873 | " responseJSON = {}; ", 874 | " tests['response is valid JSON'] = false;", 875 | "}", 876 | "", 877 | "", 878 | "tests['response has PUT data'] = _.has(responseJSON, 'data');", 879 | "tests['response matches the data sent in request'] = (responseJSON.data && responseJSON.data.length === 256);" 880 | ] 881 | } 882 | } 883 | ], 884 | "request": { 885 | "method": "DELETE", 886 | "header": [ 887 | { 888 | "key": "Content-Type", 889 | "value": "application/x-www-form-urlencoded" 890 | }, 891 | { 892 | "key": "Content-Length", 893 | "value": "1000", 894 | "disabled": true 895 | } 896 | ], 897 | "body": { 898 | "mode": "urlencoded", 899 | "urlencoded": [ 900 | { 901 | "key": "dsfs", 902 | "value": "sfdds", 903 | "description": "", 904 | "type": "text" 905 | }, 906 | { 907 | "key": "sfdsdf", 908 | "value": "sdf", 909 | "description": "", 910 | "type": "text" 911 | } 912 | ] 913 | }, 914 | "url": { 915 | "raw": "https://postman-echo.com/delete", 916 | "protocol": "https", 917 | "host": [ 918 | "postman-echo", 919 | "com" 920 | ], 921 | "path": [ 922 | "delete" 923 | ] 924 | }, 925 | "description": "The HTTP `DELETE` method is used to delete resources on a server. The exact\nuse of `DELETE` requests depends on the server implementation. In general, \n`DELETE` requests support both, Query String parameters as well as a Request \nBody.\n\nThis endpoint accepts an HTTP `DELETE` request and provides debug information\nsuch as the HTTP headers, Query String arguments, and the Request Body." 926 | }, 927 | "response": [] 928 | }, 929 | { 930 | "name": "OPTIONS to postman echo", 931 | "event": [ 932 | { 933 | "listen": "test", 934 | "script": { 935 | "type": "text/javascript", 936 | "exec": [ 937 | "var responseJSON;", 938 | "", 939 | "try { ", 940 | " responseJSON = JSON.parse(responseBody); ", 941 | " tests['response is valid JSON'] = true;", 942 | "}", 943 | "catch (e) { ", 944 | " responseJSON = {}; ", 945 | " tests['response is valid JSON'] = false;", 946 | "}", 947 | "", 948 | "", 949 | "tests['response has post data'] = _.has(responseJSON, 'data');", 950 | "tests['response matches the data posted'] = (responseJSON.data && responseJSON.data.length === 256);", 951 | "", 952 | "tests[\"content-type equals text/plain\"] = responseJSON && responseJSON.headers && (responseJSON.headers[\"content-type\"] === 'text/plain');" 953 | ] 954 | } 955 | } 956 | ], 957 | "request": { 958 | "method": "OPTIONS", 959 | "header": [ 960 | { 961 | "key": "Content-Type", 962 | "value": "application/x-www-form-urlencoded" 963 | } 964 | ], 965 | "body": {}, 966 | "url": { 967 | "raw": "https://postman-echo.com/post", 968 | "protocol": "https", 969 | "host": [ 970 | "postman-echo", 971 | "com" 972 | ], 973 | "path": [ 974 | "post" 975 | ] 976 | }, 977 | "description": "The HTTP `POST` request method is meant to transfer data to a server \n(and elicit a response). What data is returned depends on the implementation\nof the server.\n\nA `POST` request can pass parameters to the server using \"Query String \nParameters\", as well as the Request Body. For example, in the following request,\n\n> POST /hi/there?hand=wave\n>\n> \n\nThe parameter \"hand\" has the value \"wave\". The request body can be in multiple\nformats. These formats are defined by the MIME type of the request. The MIME \nType can be set using the ``Content-Type`` HTTP header. The most commonly used \nMIME types are:\n\n* `multipart/form-data`\n* `application/x-www-form-urlencoded`\n* `application/json`\n\nThis endpoint echoes the HTTP headers, request parameters, the contents of\nthe request body and the complete URI requested." 978 | }, 979 | "response": [] 980 | }, 981 | { 982 | "name": "HEAD request", 983 | "request": { 984 | "method": "HEAD", 985 | "header": [ 986 | { 987 | "key": "hello", 988 | "value": "helloagain", 989 | "disabled": true 990 | } 991 | ], 992 | "body": {}, 993 | "url": { 994 | "raw": "https://www.postman-echo.com/head", 995 | "protocol": "https", 996 | "host": [ 997 | "www", 998 | "postman-echo", 999 | "com" 1000 | ], 1001 | "path": [ 1002 | "head" 1003 | ] 1004 | }, 1005 | "description": null 1006 | }, 1007 | "response": [] 1008 | }, 1009 | { 1010 | "name": "LINK request", 1011 | "request": { 1012 | "method": "LINK", 1013 | "header": [ 1014 | { 1015 | "key": "Content-Type", 1016 | "value": "text/plain" 1017 | } 1018 | ], 1019 | "body": { 1020 | "mode": "raw", 1021 | "raw": "" 1022 | }, 1023 | "url": { 1024 | "raw": "https://mockbin.org/request", 1025 | "protocol": "https", 1026 | "host": [ 1027 | "mockbin", 1028 | "org" 1029 | ], 1030 | "path": [ 1031 | "request" 1032 | ] 1033 | }, 1034 | "description": "" 1035 | }, 1036 | "response": [] 1037 | }, 1038 | { 1039 | "name": "UNLINK request", 1040 | "request": { 1041 | "method": "UNLINK", 1042 | "header": [ 1043 | { 1044 | "key": "Content-Type", 1045 | "value": "text/plain" 1046 | } 1047 | ], 1048 | "body": { 1049 | "mode": "raw", 1050 | "raw": "" 1051 | }, 1052 | "url": { 1053 | "raw": "https://mockbin.org/request", 1054 | "protocol": "https", 1055 | "host": [ 1056 | "mockbin", 1057 | "org" 1058 | ], 1059 | "path": [ 1060 | "request" 1061 | ] 1062 | }, 1063 | "description": "" 1064 | }, 1065 | "response": [] 1066 | }, 1067 | { 1068 | "name": "LOCK request", 1069 | "request": { 1070 | "method": "LOCK", 1071 | "header": [ 1072 | { 1073 | "key": "Content-Type", 1074 | "value": "text/plain" 1075 | } 1076 | ], 1077 | "body": { 1078 | "mode": "raw", 1079 | "raw": "" 1080 | }, 1081 | "url": { 1082 | "raw": "https://mockbin.org/request", 1083 | "protocol": "https", 1084 | "host": [ 1085 | "mockbin", 1086 | "org" 1087 | ], 1088 | "path": [ 1089 | "request" 1090 | ] 1091 | }, 1092 | "description": "" 1093 | }, 1094 | "response": [] 1095 | }, 1096 | { 1097 | "name": "UNLOCK request", 1098 | "request": { 1099 | "method": "UNLOCK", 1100 | "header": [], 1101 | "body": {}, 1102 | "url": { 1103 | "raw": "https://mockbin.org/request", 1104 | "protocol": "https", 1105 | "host": [ 1106 | "mockbin", 1107 | "org" 1108 | ], 1109 | "path": [ 1110 | "request" 1111 | ] 1112 | }, 1113 | "description": "" 1114 | }, 1115 | "response": [] 1116 | }, 1117 | { 1118 | "name": "PROFIND request", 1119 | "request": { 1120 | "method": "PROPFIND", 1121 | "header": [ 1122 | { 1123 | "key": "Content-Type", 1124 | "value": "text/plain" 1125 | } 1126 | ], 1127 | "body": { 1128 | "mode": "raw", 1129 | "raw": "" 1130 | }, 1131 | "url": { 1132 | "raw": "https://mockbin.org/request", 1133 | "protocol": "https", 1134 | "host": [ 1135 | "mockbin", 1136 | "org" 1137 | ], 1138 | "path": [ 1139 | "request" 1140 | ] 1141 | }, 1142 | "description": "" 1143 | }, 1144 | "response": [] 1145 | }, 1146 | { 1147 | "name": "VIEW request", 1148 | "request": { 1149 | "method": "VIEW", 1150 | "header": [ 1151 | { 1152 | "key": "Content-Type", 1153 | "value": "text/plain" 1154 | } 1155 | ], 1156 | "body": { 1157 | "mode": "raw", 1158 | "raw": "" 1159 | }, 1160 | "url": { 1161 | "raw": "https://mockbin.org/request", 1162 | "protocol": "https", 1163 | "host": [ 1164 | "mockbin", 1165 | "org" 1166 | ], 1167 | "path": [ 1168 | "request" 1169 | ] 1170 | }, 1171 | "description": "" 1172 | }, 1173 | "response": [] 1174 | }, 1175 | { 1176 | "name": "PURGE Request", 1177 | "request": { 1178 | "method": "PURGE", 1179 | "header": [], 1180 | "body": {}, 1181 | "url": { 1182 | "raw": "https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io", 1183 | "protocol": "https", 1184 | "host": [ 1185 | "9c76407d-5b8d-4b22-99fb-8c47a85d9848", 1186 | "mock", 1187 | "pstmn", 1188 | "io" 1189 | ] 1190 | }, 1191 | "description": null 1192 | }, 1193 | "response": [ 1194 | { 1195 | "id": "c0d81a4f-46ee-4ce4-a602-37b7d55b9983", 1196 | "name": "PURGE Request", 1197 | "originalRequest": { 1198 | "method": "PURGE", 1199 | "header": [], 1200 | "body": {}, 1201 | "url": { 1202 | "raw": "https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io", 1203 | "protocol": "https", 1204 | "host": [ 1205 | "9c76407d-5b8d-4b22-99fb-8c47a85d9848", 1206 | "mock", 1207 | "pstmn", 1208 | "io" 1209 | ] 1210 | } 1211 | }, 1212 | "status": "Not Found", 1213 | "code": 404, 1214 | "_postman_previewlanguage": "text", 1215 | "header": [ 1216 | { 1217 | "key": "Access-Control-Allow-Credentials", 1218 | "value": "", 1219 | "name": "Access-Control-Allow-Credentials", 1220 | "description": "" 1221 | }, 1222 | { 1223 | "key": "Access-Control-Allow-Headers", 1224 | "value": "", 1225 | "name": "Access-Control-Allow-Headers", 1226 | "description": "" 1227 | }, 1228 | { 1229 | "key": "Access-Control-Allow-Methods", 1230 | "value": "", 1231 | "name": "Access-Control-Allow-Methods", 1232 | "description": "" 1233 | }, 1234 | { 1235 | "key": "Access-Control-Allow-Origin", 1236 | "value": "*", 1237 | "name": "Access-Control-Allow-Origin", 1238 | "description": "" 1239 | }, 1240 | { 1241 | "key": "Access-Control-Expose-Headers", 1242 | "value": "", 1243 | "name": "Access-Control-Expose-Headers", 1244 | "description": "" 1245 | }, 1246 | { 1247 | "key": "Connection", 1248 | "value": "keep-alive", 1249 | "name": "Connection", 1250 | "description": "" 1251 | }, 1252 | { 1253 | "key": "Content-Encoding", 1254 | "value": "gzip", 1255 | "name": "Content-Encoding", 1256 | "description": "" 1257 | }, 1258 | { 1259 | "key": "Content-Length", 1260 | "value": "152", 1261 | "name": "Content-Length", 1262 | "description": "" 1263 | }, 1264 | { 1265 | "key": "Content-Type", 1266 | "value": "application/json; charset=utf-8", 1267 | "name": "Content-Type", 1268 | "description": "" 1269 | }, 1270 | { 1271 | "key": "Date", 1272 | "value": "Tue, 13 Feb 2018 13:58:56 GMT", 1273 | "name": "Date", 1274 | "description": "" 1275 | }, 1276 | { 1277 | "key": "ETag", 1278 | "value": "W/\"a7-kIxN5L9H0YwilUQPUUio9A\"", 1279 | "name": "ETag", 1280 | "description": "" 1281 | }, 1282 | { 1283 | "key": "Server", 1284 | "value": "nginx", 1285 | "name": "Server", 1286 | "description": "" 1287 | }, 1288 | { 1289 | "key": "Vary", 1290 | "value": "Accept-Encoding", 1291 | "name": "Vary", 1292 | "description": "" 1293 | } 1294 | ], 1295 | "cookie": [], 1296 | "responseTime": "375", 1297 | "body": "{\n \"args\": {},\n \"data\": \"Curabitur auctor, elit nec pulvinar porttitor, ex augue condimentum enim, eget suscipit urna felis quis neque.\\nSuspendisse sit amet luctus massa, nec venenatis mi. Suspendisse tincidunt massa at nibh efficitur fringilla. Nam quis congue mi. Etiam volutpat.\",\n \"files\": {},\n \"form\": {},\n \"headers\": {\n \"host\": \"postman-echo.com\",\n \"content-length\": \"256\",\n \"accept\": \"*/*\",\n \"accept-encoding\": \"gzip, deflate\",\n \"content-type\": \"text/plain\",\n \"cookie\": \"sails.sid=s%3A1wOi4AdoZEbqBjGi6oSUC5Vlfje8wJvs.DHQfRLXfIBvZ%2Bv0KhLAThMDz%2FXvxh9gyxWYa0u1EZOU\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"x-forwarded-port\": \"443\",\n \"x-forwarded-proto\": \"https\"\n },\n \"json\": null,\n \"url\": \"https://9c76407d-5b8d-4b22-99fb-8c47a85d9848.mock.pstmn.io\"\n}" 1298 | } 1299 | ] 1300 | }, 1301 | { 1302 | "name": "COPY Request", 1303 | "request": { 1304 | "method": "COPY", 1305 | "header": [], 1306 | "body": {}, 1307 | "url": { 1308 | "raw": "https://mockbin.org/request", 1309 | "protocol": "https", 1310 | "host": [ 1311 | "mockbin", 1312 | "org" 1313 | ], 1314 | "path": [ 1315 | "request" 1316 | ] 1317 | }, 1318 | "description": null 1319 | }, 1320 | "response": [ 1321 | { 1322 | "id": "6367d22f-0cf7-48f2-a41d-5b9ed11cbff5", 1323 | "name": "COPY Request", 1324 | "originalRequest": { 1325 | "method": "COPY", 1326 | "header": [], 1327 | "body": {}, 1328 | "url": { 1329 | "raw": "https://mockbin.org/request", 1330 | "protocol": "https", 1331 | "host": [ 1332 | "mockbin", 1333 | "org" 1334 | ], 1335 | "path": [ 1336 | "request" 1337 | ] 1338 | } 1339 | }, 1340 | "status": "OK", 1341 | "code": 200, 1342 | "_postman_previewlanguage": "json", 1343 | "header": [ 1344 | { 1345 | "key": "Access-Control-Allow-Credentials", 1346 | "value": "true", 1347 | "name": "Access-Control-Allow-Credentials", 1348 | "description": "Indicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials." 1349 | }, 1350 | { 1351 | "key": "Access-Control-Allow-Headers", 1352 | "value": "host,connection,accept-encoding,x-forwarded-for,cf-ray,x-forwarded-proto,cf-visitor,cache-control,postman-token,user-agent,accept,cookie,cf-connecting-ip,x-request-id,x-forwarded-port,via,connect-time,x-request-start,total-route-time,content-length", 1353 | "name": "Access-Control-Allow-Headers", 1354 | "description": "Used in response to a preflight request to indicate which HTTP headers can be used when making the actual request." 1355 | }, 1356 | { 1357 | "key": "Access-Control-Allow-Methods", 1358 | "value": "COPY", 1359 | "name": "Access-Control-Allow-Methods", 1360 | "description": "Specifies the method or methods allowed when accessing the resource. This is used in response to a preflight request." 1361 | }, 1362 | { 1363 | "key": "Access-Control-Allow-Origin", 1364 | "value": "*", 1365 | "name": "Access-Control-Allow-Origin", 1366 | "description": "Specifies a URI that may access the resource. For requests without credentials, the server may specify '*' as a wildcard, thereby allowing any origin to access the resource." 1367 | }, 1368 | { 1369 | "key": "CF-RAY", 1370 | "value": "3fb595d5facaa302-HKG", 1371 | "name": "CF-RAY", 1372 | "description": "Custom header" 1373 | }, 1374 | { 1375 | "key": "Connection", 1376 | "value": "keep-alive", 1377 | "name": "Connection", 1378 | "description": "Options that are desired for the connection" 1379 | }, 1380 | { 1381 | "key": "Content-Encoding", 1382 | "value": "gzip", 1383 | "name": "Content-Encoding", 1384 | "description": "The type of encoding used on the data." 1385 | }, 1386 | { 1387 | "key": "Content-Type", 1388 | "value": "application/json; charset=utf-8", 1389 | "name": "Content-Type", 1390 | "description": "The mime type of this content" 1391 | }, 1392 | { 1393 | "key": "Date", 1394 | "value": "Wed, 14 Mar 2018 09:06:37 GMT", 1395 | "name": "Date", 1396 | "description": "The date and time that the message was sent" 1397 | }, 1398 | { 1399 | "key": "Etag", 1400 | "value": "W/\"4ac-YP9NIoQ5TiGJRPuQSZMKtA\"", 1401 | "name": "Etag", 1402 | "description": "An identifier for a specific version of a resource, often a message digest" 1403 | }, 1404 | { 1405 | "key": "Expect-CT", 1406 | "value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"", 1407 | "name": "Expect-CT", 1408 | "description": "Custom header" 1409 | }, 1410 | { 1411 | "key": "Server", 1412 | "value": "cloudflare", 1413 | "name": "Server", 1414 | "description": "A name for the server" 1415 | }, 1416 | { 1417 | "key": "Transfer-Encoding", 1418 | "value": "chunked", 1419 | "name": "Transfer-Encoding", 1420 | "description": "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." 1421 | }, 1422 | { 1423 | "key": "Vary", 1424 | "value": "Accept, Accept-Encoding", 1425 | "name": "Vary", 1426 | "description": "Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server." 1427 | }, 1428 | { 1429 | "key": "Via", 1430 | "value": "1.1 vegur", 1431 | "name": "Via", 1432 | "description": "Informs the client of proxies through which the response was sent." 1433 | }, 1434 | { 1435 | "key": "X-Powered-By", 1436 | "value": "mockbin", 1437 | "name": "X-Powered-By", 1438 | "description": "Specifies the technology (ASP.NET, PHP, JBoss, e.g.) supporting the web application (version details are often in X-Runtime, X-Version, or X-AspNet-Version)" 1439 | } 1440 | ], 1441 | "cookie": [ 1442 | { 1443 | "expires": "Thu Mar 14 2019 13:12:10 GMT+0530 (IST)", 1444 | "httpOnly": true, 1445 | "domain": "mockbin.org", 1446 | "path": "/", 1447 | "secure": false, 1448 | "value": "dfb94a3e1f3f8a9956138e4896847caf21521013330", 1449 | "key": "__cfduid" 1450 | } 1451 | ], 1452 | "body": "{\n \"startedDateTime\": \"2018-03-14T09:06:37.443Z\",\n \"clientIPAddress\": \"106.51.70.154\",\n \"method\": \"COPY\",\n \"url\": \"https://mockbin.org/request\",\n \"httpVersion\": \"HTTP/1.1\",\n \"cookies\": {\n \"__cfduid\": \"dfb94a3e1f3f8a9956138e4896847caf21521013330\"\n },\n \"headers\": {\n \"host\": \"mockbin.org\",\n \"connection\": \"close\",\n \"accept-encoding\": \"gzip\",\n \"x-forwarded-for\": \"106.51.70.154, 172.68.255.127\",\n \"cf-ray\": \"3fb595d5facaa302-HKG\",\n \"x-forwarded-proto\": \"http\",\n \"cf-visitor\": \"{\\\"scheme\\\":\\\"https\\\"}\",\n \"cache-control\": \"no-cache\",\n \"postman-token\": \"8d5b9832-75df-432f-90a3-284dacef0478\",\n \"user-agent\": \"PostmanRuntime/7.1.1\",\n \"accept\": \"*/*\",\n \"cookie\": \"__cfduid=dfb94a3e1f3f8a9956138e4896847caf21521013330\",\n \"cf-connecting-ip\": \"106.51.70.154\",\n \"x-request-id\": \"0e41473d-5130-4a6e-968d-b2a16cda3364\",\n \"x-forwarded-port\": \"80\",\n \"via\": \"1.1 vegur\",\n \"connect-time\": \"2\",\n \"x-request-start\": \"1521018397437\",\n \"total-route-time\": \"0\",\n \"content-length\": \"0\"\n },\n \"queryString\": {},\n \"postData\": {\n \"mimeType\": \"application/octet-stream\",\n \"text\": \"\",\n \"params\": []\n },\n \"headersSize\": 637,\n \"bodySize\": 0\n}" 1453 | } 1454 | ] 1455 | } 1456 | ] 1457 | } --------------------------------------------------------------------------------