{"id":18862200,"url":"https://github.com/hapinessjs/http-module","last_synced_at":"2026-02-09T22:30:19.859Z","repository":{"id":57115142,"uuid":"87907862","full_name":"hapinessjs/http-module","owner":"hapinessjs","description":"HTTP module for Hapiness framework","archived":false,"fork":false,"pushed_at":"2018-11-28T07:47:15.000Z","size":178,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-30T20:49:17.384Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hapinessjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-11T08:14:02.000Z","updated_at":"2021-03-30T17:02:31.000Z","dependencies_parsed_at":"2022-08-22T11:41:13.130Z","dependency_job_id":null,"html_url":"https://github.com/hapinessjs/http-module","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fhttp-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fhttp-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fhttp-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hapinessjs%2Fhttp-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hapinessjs","download_url":"https://codeload.github.com/hapinessjs/http-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239803161,"owners_count":19699622,"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":[],"created_at":"2024-11-08T04:33:37.592Z","updated_at":"2026-02-09T22:30:19.785Z","avatar_url":"https://github.com/hapinessjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"http://bit.ly/2mxmKKI\" width=\"500\" alt=\"Hapiness\" /\u003e\n\n\u003cdiv style=\"margin-bottom:20px;\"\u003e\n\u003cdiv style=\"line-height:60px\"\u003e\n    \u003ca href=\"https://travis-ci.org/hapinessjs/http-module.svg?branch=master\"\u003e\n        \u003cimg src=\"https://travis-ci.org/hapinessjs/http-module.svg?branch=master\" alt=\"build\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://coveralls.io/github/hapinessjs/http-module?branch=master\"\u003e\n        \u003cimg src=\"https://coveralls.io/repos/github/hapinessjs/http-module/badge.svg?branch=master\" alt=\"coveralls\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://david-dm.org/hapinessjs/http-module\"\u003e\n        \u003cimg src=\"https://david-dm.org/hapinessjs/http-module.svg\" alt=\"dependencies\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://david-dm.org/hapinessjs/http-module?type=dev\"\u003e\n        \u003cimg src=\"https://david-dm.org/hapinessjs/http-module/dev-status.svg\" alt=\"devDependencies\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n    \u003ca href=\"https://www.typescriptlang.org/docs/tutorial.html\"\u003e\n        \u003cimg src=\"https://cdn-images-1.medium.com/max/800/1*8lKzkDJVWuVbqumysxMRYw.png\"\n             align=\"right\" alt=\"Typescript logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://reactivex.io/rxjs\"\u003e\n        \u003cimg src=\"http://reactivex.io/assets/Rx_Logo_S.png\"\n             align=\"right\" alt=\"ReactiveX logo\" width=\"50\" height=\"50\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://hapijs.com\"\u003e\n        \u003cimg src=\"http://bit.ly/2lYPYPw\"\n             align=\"right\" alt=\"Hapijs logo\" width=\"75\" style=\"border:none;\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n# Http Module\n\n`Http` Module for the [Hapiness](https://github.com/hapinessjs/hapiness) framework, allowing user to deal with `http` request.\n\n## Table of contents\n\n* [Using http module inside Hapiness application](#using-http-module-inside-hapiness-application)\n    * [Yarn or NPM it in your package.json](#yarn-or-npm-it-in-your-packagejson)\n    * [Import HttpModule](#import-httpmodule)\n    * [Use it anywhere](#use-it-anywhere)\n* [Validate Response](#validateResponse-operator)\n* [API in Detail](#api-in-detail)\n* [Contributing](#contributing)\n* [Change History](#change-history)\n* [Maintainers](#maintainers)\n* [License](#license)\n    \n## Using http module inside Hapiness application\n\n### `yarn` or `npm` it in your `package.json`\n\n```bash\n$ npm install --save @hapiness/http @hapiness/biim @hapiness/core rxjs\n\nor\n\n$ yarn add @hapiness/http @hapiness/biim @hapiness/core rxjs\n```\n\n```javascript\n\"dependencies\": {\n    \"@hapiness/biim\": \"^1.4.0\",\n    \"@hapiness/core\": \"^1.3.0\",\n    \"@hapiness/http\": \"^1.1.2\",\n    \"rxjs\": \"^5.5.6\",\n    //...\n}\n//...\n```\n\n### import `HttpModule`\n\n```javascript\nimport { HapinessModule } from '@hapiness/core';\nimport { HttpModule } from '@hapiness/http';\n\n@HapinessModule({\n    version: '1.0.0',\n    declarations: [\n        LibWithHttpCalls\n    ],\n    imports: [\n        HttpModule\n    ]\n})\nclass HapinessModuleNeedsHttpModule {}\n```\n\n### use it anywhere\n\nYou can use `HttpService` anywhere in your module with **dependency injection**.\n\n```javascript\nimport { Lib } from '@hapiness/core';\nimport { HttpService } from '@hapiness/http';\n\n@Lib()\nclass LibWithHttpCalls {\n    constructor(private _http: HttpService){}\n    \n    crawlWebPage(): void {\n        this._http.get('http://www.google.fr').subscribe(\n            (data) =\u003e {\n        \n                if (data.response.statusCode === 200) {\n                    console.log(data.body); // Show the HTML for the Google homepage.\n                }\n            },\n            (err) =\u003e console.error(err) // Show error in console\n        );\n    }\n}\n```\n\n[Back to top](#table-of-contents)\n\n## validateResponse operator\n\nFormat your data with the Joi Schema validation and throw an error in the Observable if statusCode \u003e= 400\n\n`validateResponse(\u003cJoi.Schema\u003e, [ignoredStatusCodes?])`\n\n```javascript\nimport { Lib } from '@hapiness/core';\nimport { HttpService } from '@hapiness/http';\nimport '@hapiness/http/observable/add/validateResponse';\n\n@Lib()\nclass LibWithHttpCalls {\n    constructor(private _http: HttpService){}\n    \n    crawlWebPage(): void {\n        this._http.get('http://my-api/data')\n            .validateResponse(MySchema)\n            .subscribe(\n                (data) =\u003e console.log(data),\n                (err) =\u003e console.error(err) // Show error in console\n            );\n    }\n}\n```\n\n## API in Detail\n\nThis module is an **encapsulation** of [Rx-Http-Request](https://github.com/njl07/rx-http-request) library to allow their features inside [Hapiness](https://github.com/hapinessjs/hapiness) framework.\n\nMethods implemented are:\n\n* `.request`\n* `.get(uri[, options])`\n* `.getBuffer(uri[, options])`\n* `.post(uri[, options])`\n* `.put(uri[, options])`\n* `.patch(uri[, options])`\n* `.delete(uri[, options])`\n* `.head(uri[, options])`\n* `.jar()`\n* `.cookie(str)`\n\nIf you want to have all **details** for these methods, see [Rx-Http-Request's API details](https://github.com/njl07/rx-http-request#api-in-detail).\n\n[Back to top](#table-of-contents)\n\n## Contributing\n\nTo set up your development environment:\n\n1. clone the repo to your workspace,\n2. in the shell `cd` to the main folder,\n3. hit `npm or yarn install`,\n4. run `npm or yarn run test`.\n    * It will lint the code and execute all tests. \n    * The test coverage report can be viewed from `./coverage/lcov-report/index.html`.\n\n[Back to top](#table-of-contents)\n\n## Change History\n* v1.1.2 (2018-01-29)\n    * Latest packages' versions.\n    * Documentation.\n    * Fix error message on body.\n* v1.1.1 (2017-11-20)\n    * Latest packages' versions.\n    * Documentation.\n    * Change packaging process.\n* v1.0.0 (2017-10-12)\n    * First stable version\n    * Implementation of all features.\n    * Version related to `core` version\n    \n[Back to top](#table-of-contents)\n\n## Maintainers\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd colspan=\"4\" align=\"center\"\u003e\u003ca href=\"https://www.tadaweb.com\"\u003e\u003cimg src=\"http://bit.ly/2xHQkTi\" width=\"117\" alt=\"tadaweb\" /\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6546204?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/997028?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/6841511?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1673977?v=3\u0026s=117\" width=\"117\"/\u003e\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Juneil\"\u003eJulien Fauville\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/antoinegomez\"\u003eAntoine Gomez\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/reptilbud\"\u003eSébastien Ritz\u003c/a\u003e\u003c/td\u003e\n        \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/njl07\"\u003eNicolas Jessel\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n[Back to top](#table-of-contents)\n\n## License\n\nCopyright (c) 2017 **Hapiness** Licensed under the [MIT license](https://github.com/hapinessjs/http-module/blob/master/LICENSE.md).\n\n[Back to top](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fhttp-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhapinessjs%2Fhttp-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhapinessjs%2Fhttp-module/lists"}