{"id":15650942,"url":"https://github.com/char0n/http-request-in-editor","last_synced_at":"2025-04-15T17:47:08.647Z","repository":{"id":36973286,"uuid":"239177040","full_name":"char0n/http-request-in-editor","owner":"char0n","description":"Reference implementation of HTTP Request in Editor Specification https://github.com/JetBrains/http-request-in-editor-spec","archived":false,"fork":false,"pushed_at":"2024-09-12T05:15:54.000Z","size":1393,"stargazers_count":34,"open_issues_count":17,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T00:44:00.105Z","etag":null,"topics":["editor","hacktoberfest","http","spec"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/char0n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":"GOVERNANCE.md","roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["char0n"],"patreon":"char0n","ko_fi":"char0n","liberapay":"char0n","issuehunt":"char0n"}},"created_at":"2020-02-08T17:51:35.000Z","updated_at":"2024-07-29T05:27:41.000Z","dependencies_parsed_at":"2023-12-18T06:26:15.135Z","dependency_job_id":"ba032363-6775-4249-8f8c-1002c0722c20","html_url":"https://github.com/char0n/http-request-in-editor","commit_stats":{"total_commits":572,"total_committers":3,"mean_commits":"190.66666666666666","dds":"0.34090909090909094","last_synced_commit":"6b06a3bdc8ee992e557cce6d652ad0bfbfc25f43"},"previous_names":["char0n/http-request-in-editor-impl"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/char0n%2Fhttp-request-in-editor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/char0n%2Fhttp-request-in-editor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/char0n%2Fhttp-request-in-editor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/char0n%2Fhttp-request-in-editor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/char0n","download_url":"https://codeload.github.com/char0n/http-request-in-editor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501927,"owners_count":21114681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["editor","hacktoberfest","http","spec"],"created_at":"2024-10-03T12:36:20.822Z","updated_at":"2025-04-15T17:47:08.624Z","avatar_url":"https://github.com/char0n.png","language":"JavaScript","readme":"[![Node CI](https://github.com/char0n/http-request-in-editor/workflows/Node.js%20CI/badge.svg)](https://github.com/char0n/http-request-in-editor/actions?query=workflow%3A%22Node.js+CI%22)\n\n# HTTP Request in Editor Implementation\n\n## What is this?\n\n[JetBrains company](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html) has come up with\nwith very interesting concept called [HTTP Request in Editor Spec](https://github.com/JetBrains/http-request-in-editor-spec/blob/master/spec.md).\nThey implemented this spec into their [IDEs](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html).\nYou are able to create files with `.http` extensions with nice syntax highlighting and run HTTP requests directly in your editor.\nEventually you can create collection of these `.http` files, check them in as part of your codebase and\nshare them with the rest of your team. This is really great...but...\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://resources.jetbrains.com/help/img/idea/2019.3/basic_request.png\" /\u003e\u003c/p\u003e\n\nThere is currently no [CLI](https://en.wikipedia.org/wiki/Command-line_interface) runner for `.http` files. From the\nmoment we checked our `.http` files inside our project we should test if those file reflect reality.\nThis project provides tool for running `.http` files on your [CI](https://en.wikipedia.org/wiki/Continuous_integration).\n\n**Warning:** Currently we have only implemented the parser which creates documented CST. We're working hard on implementation\nof runner compatible with JetBrains one. Stay tuned for the runner!\n\n\u003chr /\u003e\n\nThis repo contains reference implementation of [HTTP Request in Editor Spec](https://github.com/JetBrains/http-request-in-editor-spec/blob/master/spec.md) parser.\n\nThe [HTTP Request in Editor Spec](https://github.com/JetBrains/http-request-in-editor-spec/blob/master/spec.md) is using context-free grammar to present set of production rules.\nWe're using [nearley](https://nearley.js.org/) to declaratively map this grammar and generate a JavaScript parser from it.\n\nParser can parse following syntax and creates [CST](https://en.wikipedia.org/wiki/Parse_tree)\nthat can be consumed and executed by various runtime environments. I'll provide a reference implementation\nof a reference runtime implementation as soon as the parser is finished.\n\n```\n### request 1\nPOST https://httpbin.org/post HTTP/1.1\nAuthorization: token\n\nrequest body 1\n\n### request 2\nPOST https://httpbin.org/post HTTP/2.0\nAuthorization: token2\n\n{\n  \"test\": 3,\n  \"a\": \"b\"\n}\n\n### request 3\nPOST https://httpbin.org/post HTTP/3.0\nAuthorization: token3\n\n{}\n\n###\n```\n\n## Installation\n\n```sh\n $ npm i http-request-in-editor\n```\n\n## Parser\n\n```js\nconst { parse } = require('http-request-in-editor');\n\n\nconst http = `\nPOST https://httpbin.org/post\n\n###\n`;\n\nconst cst = parse(http);\n// now process the CST with your favorite http library\n```\n\n\n### CST\n\nParser is producing JSON serializable [CST](https://en.wikipedia.org/wiki/Parse_tree). Following [HTTP Request in Editor](https://github.com/JetBrains/http-request-in-editor-spec/blob/master/spec.md) fragment\n\n```\n### post request\nPOST http://www.example.com HTTP/2.0\n# comment\nAuthorization: token\n\nmessage body\n\n\u003e {% script %}\n\u003c\u003e ./file.json\n\n###\n```\n\nwill produce following CST:\n\n```\n(requests-file\n  (request\n    (requests-line\n      (method)\n      (request-target\n        (absolute-form\n          (scheme)\n          (literal)\n          (hier-part\n            (authority\n              (host\n                (ipv4-or-reg-name))))))\n      (http-version))\n    (headers\n      (header-field\n        (field-name)\n        (field-value)))\n    (message-body\n      (messages\n        (message-line)\n        (message-line)))\n    (response-handler\n      (handler-script))\n    (response-ref\n      (file-path))))\n```\n\nCST should be self-explanatory. For more information checkout our [CST Types](https://github.com/char0n/http-request-in-editor/tree/master/src/parser/cst).\n\n## Runner\n\n```js\nconst fs = require('fs');\nconst { runSpec } = require('http-request-in-editor');\n\nconst spec = fs.readFileSync('./spec-file.http');\nconst result = await runSpec(spec); // returns list of response objects\n```\n\n## Development\n\nFork the repo, clone in and install by\n\n```sh\n $ npm i\n```\n\nEdit `src/parser/grammer.ne` and create a grammar that maps to HTTP Request in Editor Spec.\n\nCompiles `src/parser/grammar.ne` file into `src/parser/grammar.js`.\n```sh\n $ npm run compile\n```\n\nTest parser grammar against predefined fixtures.\n```sh\n $ npm test\n```\n\nGenerate railroad diagrams from `src/parser/grammar.ne` file.\n```sh\n $ npm run railroad\n```\n\nGenerate random strings that satisfy the grammar defined in`src/parser/grammar.ne` file.\n```sh\n $ npm run unparse\n```\n\nRegenerates [Corpus file](https://github.com/char0n/http-request-in-editor/tree/master/test/corpus/corpus.txt). Replaces CST S-expression representation with the new one.\n```sh\n $ npm run corpus:regenerate\n```\n\nLint the source code.\n```sh\n $ npm run lint\n```\n\n## Notes\n\n\n1. `Multipart-form-data` will not be part of resulting CST. It's just a special shape of `message-body` and requires\nno special handling even during runtime.\n","funding_links":["https://github.com/sponsors/char0n","https://patreon.com/char0n","https://ko-fi.com/char0n","https://liberapay.com/char0n","https://issuehunt.io/r/char0n"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchar0n%2Fhttp-request-in-editor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchar0n%2Fhttp-request-in-editor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchar0n%2Fhttp-request-in-editor/lists"}