insomnia/packages/insomnia-httpsnippet
Gregory Schier 605cb90753
Update Electron and node-libcurl (#1215)
* A bunch of things

* Publish

 - insomnia-app@1.0.41
 - insomnia-cookies@0.0.8
 - insomnia-httpsnippet@1.16.13
 - insomnia-importers@2.0.7
 - insomnia-libcurl@0.0.17
 - insomnia-url@0.1.4
 - insomnia-xpath@1.0.5
 - insomnia-plugin-cookie-jar@1.0.3
 - insomnia-plugin-jsonpath@1.0.7
 - insomnia-plugin-now@1.0.7
 - insomnia-plugin-os@1.0.9
 - insomnia-plugin-prompt@1.1.7
 - insomnia-plugin-request@1.0.13
 - insomnia-plugin-response@1.0.11
 - insomnia-plugin-uuid@1.0.6

* Package deps

* Remove fsevents again

* Appveyor node verison

* Remove unused dep

* Try something

* Try another thing

* NPM audit

* Yet again

* Fix test

* Fix test

* Remove npm dep

* Fix webview

* Fix React sortable and bump version

* Comment out broken test for now

* Publish

 - insomnia-app@1.0.42
 - insomnia-cookies@0.0.9
 - insomnia-httpsnippet@1.16.14
 - insomnia-importers@2.0.8
 - insomnia-libcurl@0.0.18
 - insomnia-xpath@1.0.6
 - insomnia-plugin-cookie-jar@1.0.4
 - insomnia-plugin-file@1.0.5
 - insomnia-plugin-jsonpath@1.0.8
 - insomnia-plugin-now@1.0.8
 - insomnia-plugin-os@1.0.10
 - insomnia-plugin-request@1.0.14
 - insomnia-plugin-response@1.0.12
 - insomnia-plugin-uuid@1.0.7

* Remove deprecated Electron Builder config options

* Try some more

* Publish

 - insomnia-app@1.0.43
 - insomnia-libcurl@0.0.19

* Bump

* Publish

 - insomnia-app@1.0.44
 - insomnia-libcurl@0.0.20

* Hopefully fix windows builds

* DEBUG on travis

* Hopefully fix dependency issues

* Undo package-lock copy

* Debug

* More debugging

* Another check

* Fix debug check

* Try just build

* Extra logging

* Escape windows paths differently (Fixes #1217)

* Try packing more deps

* Publish

 - insomnia-app@1.0.45
 - insomnia-cookies@0.0.10
 - insomnia-httpsnippet@1.16.15
 - insomnia-importers@2.0.9
 - insomnia-libcurl@0.0.21
 - insomnia-xpath@1.0.7
 - insomnia-plugin-cookie-jar@1.0.5
 - insomnia-plugin-jsonpath@1.0.9
 - insomnia-plugin-now@1.0.9
 - insomnia-plugin-os@1.0.11
 - insomnia-plugin-request@1.0.15
 - insomnia-plugin-response@1.0.13
 - insomnia-plugin-uuid@1.0.8

* Adjust some deps

* Zip build dir into release files

* More debug info

* Undo travis tar debug

* Downgrade electron-builder to 20.19

* Downgrade electron-builder to last working version

* Try electron-builder 20.20.4

* Change bundled deps

* Add electron-builder-lib back
2018-10-19 22:11:58 -04:00
..
bin
src
test
.editorconfig
.gitignore
.jshintrc
.npmignore
.travis.yml
CONTRIBUTING.md
LICENSE
package-lock.json
package.json
README.md
yarn.lock

HTTP Snippet version License

HTTP Request snippet generator for many languages & tools including: cURL, HTTPie, Javascript, Node, C, Java, PHP, Objective-C, Swift, Python, Ruby, C#, Go, OCaml and more!

Relies on the popular HAR format to import data and describe HTTP calls.

See it in action on companion service: APIembed

Build Status Downloads Code Climate Coverage Status Dependencies Gitter

Install

# to use in cli
npm install --global httpsnippet

# to use as a module
npm install --save httpsnippet

Usage


  Usage: httpsnippet [options] <file>

  Options:

    -h, --help                output usage information
    -V, --version             output the version number
    -t, --target <target>     target output
    -c, --client [client]     target client library
    -o, --output <directory>  write output to directory

Example

process single file: example.json in HAR Request Object format, or full HAR log format:

httpsnippet example.json --target node --client unirest --output ./snippets
$ tree snippets
snippets/
└── example.js

process multiple files:

httpsnippet ./*.json --target node --client request --output ./snippets
$ tree snippets/
snippets/
├── endpoint-1.js
├── endpoint-2.js
└── endpoint-3.js

API

HTTPSnippet(source)

source

Required
Type: object

Name of conversion target

var HTTPSnippet = require('httpsnippet');

var snippet = new HTTPSnippet({
  method: 'GET',
  url: 'http://mockbin.com/request'
});

convert(target [, options])

target

Required
Type: string

Name of conversion target

options

Type: object

Target options, see wiki for details

var HTTPSnippet = require('httpsnippet');

var snippet = new HTTPSnippet({
  method: 'GET',
  url: 'http://mockbin.com/request'
});

// generate Node.js: Native output
console.log(snippet.convert('node'));

// generate Node.js: Native output, indent with tabs
console.log(snippet.convert('node', {
  indent: '\t'
}));

convert(target [, client, options])

target

Required
Type: string

Name of conversion target

client

Type: string

Name of conversion target client library

options

Type: object

Target options, see wiki for details

var HTTPSnippet = require('httpsnippet');

var snippet = new HTTPSnippet({
  method: 'GET',
  url: 'http://mockbin.com/request'
});

// generate Shell: cURL output
console.log(snippet.convert('shell', 'curl', {
  indent: '\t'
}));

// generate Node.js: Unirest output
console.log(snippet.convert('node', 'unirest'));

Documentation

At the heart of this module is the HAR Format as the HTTP request description format, please review some of the sample JSON HAR Request objects in test fixtures, or read the HAR Docs for more details.

For detailed information on each target, please review the wiki.

Bugs and feature requests

Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

For info on creating new conversion targets, please review this guideline

More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests.

Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major while resetting minor and patch
  • New additions without breaking backward compatibility bumps the minor while resetting the patch
  • Bug fixes and misc changes bumps only the patch

For more information on SemVer, please visit http://semver.org/.

License

MIT © Mashape