Skip to content

Commit 3aef8a9

Browse files
committed
chore: update README.md and links
1 parent b2fe08a commit 3aef8a9

2 files changed

Lines changed: 37 additions & 169 deletions

File tree

README.md

Lines changed: 31 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
# HTTPSnippet
1+
# HTTPSnippet-lite
22

33
[![version][npm-version]][npm-url] [![License][npm-license]][license-url]
44

55
> 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](https://github.com/Kong/httpsnippet/wiki/Targets)!
66
77
Relies on the popular [HAR](http://www.softwareishard.com/blog/har-12-spec/#request) format to import data and describe HTTP calls.
88

9-
See it in action on companion service: [APIembed](https://apiembed.com)
9+
[![Build](https://github.com/httpsnippet-lite/workflows/CI/badge.svg)](https://github.com/httpsnippet-lite)
1010

11-
[![Build](https://github.com/Kong/httpsnippet/actions/workflows/build.yml/badge.svg)](https://github.com/Kong/httpsnippet/actions/workflows/build.yml) [![Downloads][npm-downloads]][npm-url]
12-
13-
- [HTTPSnippet](#httpsnippet)
11+
- [HTTPSnippet](#httpsnippet-lite)
1412
- [Quickstart](#quickstart)
1513
- [Core Concepts](#core-concepts)
1614
- [CLI Quickstart](#cli-quickstart)
1715
- [TypeScript Library Quickstart](#typescript-library-quickstart)
18-
- [CLI Usage](#cli-usage)
19-
- [CLI Installation](#cli-installation)
20-
- [Example](#example)
2116
- [TypeScript Library Usage](#typescript-library-usage)
2217
- [Library Installation](#library-installation)
2318
- [Types](#types)
@@ -54,153 +49,31 @@ See it in action on companion service: [APIembed](https://apiembed.com)
5449
### CLI Quickstart
5550

5651
```shell
57-
httpsnippet har.json \ # the path your input file (must be in HAR format)
58-
--target shell \ # your desired language
59-
--client curl \ # your desired language library
60-
--output ./examples \ # an output directory, otherwise will just output to Stdout
61-
--options '{ "indent": false }' # any client options as a JSON string
52+
npm install --save httpsnippet-lite
6253
```
6354

6455
### TypeScript Library Quickstart
6556

6657
```ts
67-
import { HTTPSnippet } from 'httpsnippet';
58+
import { HTTPSnippet } from 'httpsnippet-lite';
6859

6960
const snippet = new HTTPSnippet({
7061
method: 'GET',
7162
url: 'http://mockbin.com/request',
7263
});
7364

7465
const options = { indent: '\t' };
75-
const output = snippet.convert('shell', 'curl', options);
66+
const output = await snippet.convert('shell', 'curl', options);
7667
console.log(output);
7768
```
7869

79-
## CLI Usage
80-
81-
### CLI Installation
82-
83-
| NPM | Yarn |
84-
| ------------------------------------------- | -------------------------------------- |
85-
| <pre>npm install --global httpsnippet</pre> | <pre>yarn global add httpsnippet</pre> |
86-
87-
```text
88-
httpsnippet [harFilePath]
89-
90-
the default command
91-
92-
Options:
93-
--help Show help [boolean]
94-
--version Show version number [boolean]
95-
-t, --target target output [string] [required]
96-
-c, --client language client [string]
97-
-o, --output write output to directory [string]
98-
-x, --options provide extra options for the target/client [string]
99-
100-
Examples:
101-
httpsnippet my_har.json --target rust --client actix --output my_src_directory
102-
```
103-
104-
### Example
105-
106-
The input to HTTPSnippet is any valid [HAR Request Object](http://www.softwareishard.com/blog/har-12-spec/#request), or full [HAR](http://www.softwareishard.com/blog/har-12-spec/#log) log format.
107-
108-
<details>
109-
<summary>`example.json`</summary>
110-
111-
```json
112-
{
113-
"method": "POST",
114-
"url": "http://mockbin.com/har?key=value",
115-
"httpVersion": "HTTP/1.1",
116-
"queryString": [
117-
{
118-
"name": "foo",
119-
"value": "bar"
120-
},
121-
{
122-
"name": "foo",
123-
"value": "baz"
124-
},
125-
{
126-
"name": "baz",
127-
"value": "abc"
128-
}
129-
],
130-
"headers": [
131-
{
132-
"name": "accept",
133-
"value": "application/json"
134-
},
135-
{
136-
"name": "content-type",
137-
"value": "application/x-www-form-urlencoded"
138-
}
139-
],
140-
"cookies": [
141-
{
142-
"name": "foo",
143-
"value": "bar"
144-
},
145-
{
146-
"name": "bar",
147-
"value": "baz"
148-
}
149-
],
150-
"postData": {
151-
"mimeType": "application/x-www-form-urlencoded",
152-
"params": [
153-
{
154-
"name": "foo",
155-
"value": "bar"
156-
}
157-
]
158-
}
159-
}
160-
```
161-
162-
</details>
163-
164-
```shell
165-
httpsnippet example.json --target shell --client curl --output ./examples
166-
```
167-
168-
```console
169-
$ tree examples
170-
examples/
171-
└── example.sh
172-
```
173-
174-
inside `examples/example.sh` you'll see the generated output:
175-
176-
```shell
177-
curl --request POST \
178-
--url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' \
179-
--header 'accept: application/json' \
180-
--header 'content-type: application/x-www-form-urlencoded' \
181-
--cookie 'foo=bar; bar=baz' \
182-
--data foo=bar
183-
```
184-
185-
provide extra options:
186-
187-
```shell
188-
httpsnippet example.json --target shell --client curl --output ./examples --options '{ "indent": false }'
189-
```
190-
191-
and see how the output changes, in this case without indentation
192-
193-
```shell
194-
curl --request POST --url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' --header 'accept: application/json' --header 'content-type: application/x-www-form-urlencoded' --cookie 'foo=bar; bar=baz' --data foo=bar
195-
```
196-
19770
## TypeScript Library Usage
19871

19972
### Library Installation
20073

201-
| NPM | Yarn |
202-
| ----------------------------------------- | ------------------------------- |
203-
| <pre>npm install --save httpsnippet</pre> | <pre>yarn add httpsnippet</pre> |
74+
| NPM | Yarn |
75+
|------------------------------------------------|--------------------------------------|
76+
| <pre>npm install --save httpsnippet-lite</pre> | <pre>yarn add httpsnippet-lite</pre> |
20477

20578
### Types
20679

@@ -292,7 +165,7 @@ interface Target {
292165
Name of [conversion target](https://github.com/Kong/httpsnippet/wiki/Targets)
293166

294167
```ts
295-
import { HTTPSnippet } from 'httpsnippet';
168+
import { HTTPSnippet } from 'httpsnippet-lite';
296169

297170
const snippet = new HTTPSnippet({
298171
method: 'GET',
@@ -317,11 +190,11 @@ const snippet = new HTTPSnippet({
317190
});
318191

319192
// generate Node.js: Native output
320-
console.log(snippet.convert('node'));
193+
console.log(await snippet.convert('node'));
321194

322195
// generate Node.js: Native output, indent with tabs
323196
console.log(
324-
snippet.convert('node', {
197+
await snippet.convert('node', {
325198
indent: '\t',
326199
}),
327200
);
@@ -337,7 +210,7 @@ const isTarget: (target: Target) => target is Target;
337210

338211
```ts
339212
import { myCustomTarget } from './my-custom-target';
340-
import { isTarget } from 'httpsnippet';
213+
import { isTarget } from 'httpsnippet-lite';
341214

342215
try {
343216
console.log(isTarget(myCustomTarget));
@@ -357,12 +230,12 @@ const addTarget: (target: Target) => void;
357230
```ts
358231
import { myCustomClient } from './my-custom-client';
359232
import { HAR } from 'my-custom-har';
360-
import { HTTPSnippet, addTargetClient } from 'httpsnippet';
233+
import { HTTPSnippet, addTargetClient } from 'httpsnippet-lite';
361234

362235
addTargetClient(myCustomClient);
363236

364237
const snippet = new HTTPSnippet(HAR);
365-
const output = snippet.convert('customTargetId');
238+
const output = await snippet.convert('customTargetId');
366239
console.log(output);
367240
```
368241

@@ -393,34 +266,28 @@ Use `addTargetClient` to add a custom client to an existing target. See [`addTar
393266
const addTargetClient: (targetId: TargetId, client: Client) => void;
394267
```
395268

396-
```ts
397-
import { myCustomClient } from './my-custom-client';
398-
import { HAR } from 'my-custom-har';
399-
import { HTTPSnippet, addTargetClient } from 'httpsnippet';
400-
401-
addTargetClient('customTargetId', myCustomClient);
269+
## Documentation
402270

403-
const snippet = new HTTPSnippet(HAR);
404-
const output = snippet.convert('customTargetId', 'customClientId');
405-
console.log(output);
406-
```
271+
At the heart of this module is the [HAR Format](http://www.softwareishard.com/blog/har-12-spec/#request) as the HTTP request description format, please review some of the sample JSON HAR Request objects in [test fixtures](/test/fixtures/requests), or read the [HAR Docs](http://www.softwareishard.com/blog/har-12-spec/#request) for more details.
407272

408-
## Bugs and feature requests
273+
For detailed information on each target, please review the [wiki](https://github.com/Kong/httpsnippet/wiki).
409274

410-
Have a bug or a feature request? Please first read the [issue guidelines](CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](/issues).
275+
## Differences from `kong/httpsnippet`
411276

412-
## Contributing
277+
Here's a list of the most significant differences between httpsnippet-lite and [httpsnippet](https://github.com/Kong/httpsnippet) upstream:
413278

414-
Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development.
279+
* No reliance on Node.js core modules and globals
280+
* convert() method is async
281+
* HAR is not validated
282+
* CLI is not bundled
283+
* Dual packaging available
415284

416-
For info on creating new conversion targets, please review this [guideline](https://github.com/Kong/httpsnippet/wiki/Creating-Targets)
285+
## License
417286

418-
Moreover, if your pull request contains TypeScript patches or features, you must include relevant unit tests.
419-
420-
Editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <http://editorconfig.org>.
287+
[MIT](LICENSE) &copy; [Kong](https://konghq.com)
421288

422289
[license-url]: https://github.com/Kong/httpsnippet/blob/master/LICENSE
423-
[npm-url]: https://www.npmjs.com/package/httpsnippet
424-
[npm-license]: https://img.shields.io/npm/l/httpsnippet.svg?style=flat-square
425-
[npm-version]: https://img.shields.io/npm/v/httpsnippet.svg?style=flat-square
426-
[npm-downloads]: https://img.shields.io/npm/dm/httpsnippet.svg?style=flat-square
290+
291+
[npm-url]: https://www.npmjs.com/package/httpsnippet-lite
292+
[npm-license]: https://img.shields.io/npm/l/httpsnippet-lite.svg?style=flat-square
293+
[npm-version]: https://img.shields.io/npm/v/httpsnippet-lite.svg?style=flat-square

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"version": "3.0.0",
3-
"name": "httpsnippet",
3+
"name": "httpsnippet-lite",
44
"description": "HTTP Request snippet generator for *most* languages",
5-
"author": "Kong <[email protected]>",
6-
"homepage": "https://github.com/Kong/httpsnippet",
5+
"author": "Jakub Rożek",
6+
"contributors": ["Kong <[email protected]>"],
7+
"homepage": "https://github.com/P0lip/httpsnippet",
78
"license": "MIT",
89
"sideEffects": false,
910
"type": "commonjs",
@@ -50,9 +51,9 @@
5051
"engines": {
5152
"node": "^14.19.1 || ^16.14.2 || ^18.0.0"
5253
},
53-
"repository": "Kong/httpsnippet",
54+
"repository": "P0lip/httpsnippet",
5455
"bugs": {
55-
"url": "https://github.com/Kong/httpsnippet/issues"
56+
"url": "https://github.com/P0lip/httpsnippet/issues"
5657
},
5758
"scripts": {
5859
"lint": "npm run lint:prettify && npm run lint:code && npm run lint:markdown",

0 commit comments

Comments
 (0)