{"id":15750402,"url":"https://github.com/burnett01/extended-request","last_synced_at":"2025-03-13T14:32:53.285Z","repository":{"id":57231996,"uuid":"102204832","full_name":"Burnett01/extended-request","owner":"Burnett01","description":"An enhanced request module for node.js for REST-/API servers.","archived":false,"fork":false,"pushed_at":"2022-01-16T17:41:02.000Z","size":39,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T02:09:46.461Z","etag":null,"topics":["es6","gzip","http","https","node","nodejs","request","requests","response","rest","tls"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Burnett01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-02T15:12:33.000Z","updated_at":"2022-01-16T17:39:17.000Z","dependencies_parsed_at":"2022-08-31T18:33:51.920Z","dependency_job_id":null,"html_url":"https://github.com/Burnett01/extended-request","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fextended-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fextended-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fextended-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Burnett01%2Fextended-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Burnett01","download_url":"https://codeload.github.com/Burnett01/extended-request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243422848,"owners_count":20288534,"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":["es6","gzip","http","https","node","nodejs","request","requests","response","rest","tls"],"created_at":"2024-10-04T06:40:37.580Z","updated_at":"2025-03-13T14:32:48.276Z","avatar_url":"https://github.com/Burnett01.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# extended-request\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Build Status](https://travis-ci.com/Burnett01/extended-request.svg?branch=master)](https://travis-ci.com/Burnett01/extended-request) [![npm version](https://badge.fury.io/js/%40burnett01%2Fextended-request.svg)](https://badge.fury.io/js/%40burnett01%2Fextended-request)\n\nAn enhanced request module for node.js for REST-/API servers.\n\nFeatures:\n  * Supports various auth providers (Basic, Bearer, Token, PostToken, Custom ..)\n  * Supports HTTP and HTTP/S (TLS) protocols\n  * Auto response content-type negotiation (JSON, HTML, Plain, ...)\n  * GZIP compression\n  * ES6 \u0026 ES5 support\n  * Promises \u0026 classic nodeback\n  * Debugging\n\n---\n\n# Table of contents\n* [API Reference](#api-reference)\n* [Property Reference](#property-reference)\n* [Function Reference](#function-reference)\n  * [Creating a request container](#creating-a-request-container)\n  * [Performing a request](#performing-a-request)\n* [Setup / Install](#setup-install)\n* [Build](#build)\n  * [NPM](#npm)\n  * [Make](#make)\n* [Unit-Tests](#unit-tests)\n  * [NPM](#npm-1)\n  * [Make](#make-1)\n* [Contributing](#contributing)\n* [License](#license)\n\n---\n\n## API Reference\n\n```javascript\nExtendedRequest(\n    [Object {\n        host: String='',\n        port: Number='',\n        endpoint: String='',\n        auth: Object { \n            provider: String='basic|bearer|token|postToken|custom',\n            username: String='',\n            password: String='',\n            token: String='',\n            custom: String=''\n        }\n    } details]\n) -\u003e Object {\n    /* Constants */\n    this:  Object=this,\n\n    /* Methods */\n    request:  [String=path, Object {\n        method: String='GET|POST|HEAD|...',\n        type: String='text/plain|application/json|...',\n        bodyType: String='application/x-www-form-urlencoded|application/json|...',\n        body: String='',\n    } options, function(class ErrorClass err, null ok) cb] | Promise\n}\n\n/* Statics */\n\nExtendedRequest.DEBUG = true/false\n```\n\n---\n\n## Property reference:\n\n| Property | Description |\n| ------ | ----------- |\n| details | An object with some connection details |\n| options | An object containing request options |\n| host | FQDN used for requests (eg. myapi.com) |\n| port | ``Default`` = 80\n|  | 443 enables https |\n| path | URI path (eg. /get/users)\n| endpoint | ``host`` endpoint/prefix for a ``path`` (eg. /api/v1)\n| type | The HTTP Content-Type for the request. Check lib/util.js for valid types Default is BT.JSON\n| body | POST payload\n| bodyType | The type of the body payload. Check lib/util.js for valid types. Default is BT.FORM\n| auth | Authentication details \n|  |``.provider`` = Either 'basic, bearer, token, postToken, custom' |\n|  |``.username`` = Set HTTP basic auth username when provider is 'basic' |\n|  |``.password`` = Set HTTP basic auth password when provider is 'basic' |\n|  |``.token`` = \u003cbr /\u003eSet HTTP auth token (header) when provider is 'token' or 'bearer'. \u003cbr /\u003eSet POST token when provider is 'postToken' and ``request.method`` is 'POST'  |\n|  |``.custom`` = \u003cbr /\u003eSet HTTP auth header when provider is 'custom' |\n\n---\n\n## Function reference:\n\n### Creating a request container\n\n**Available options:**\n\n| |  | Required | \n| ------ | ----------- | ------ |\n| host | FQDN (eg. myapi.com) | Yes |\n| port | Port | No |\n| endpoint | Path prefix | No |\n| auth | Authentication details | No |\n\n```javascript\nconst api = new ExtendedRequest({\n  host: 'jsonplaceholder.typicode.com',\n  port: 443\n})\n```\n\n---\n\n### Performing a request\n\n**Available options:**\n\n| |  | Required | \n| ------ | ----------- | ------ |\n| method | HTTP method (Default: GET) | No |\n| type | Content-Type (Default: 'application/json') | No |\n| body | Body for a post request | If method is 'POST' |\n| bodyType | Set specific type \u003cbr /\u003e(Default: 'application/x-www-form-urlencoded')| No|\n| headers | Set optional headers object | No|\n\n```javascript\napi.request('/posts/1', (err, response) =\u003e {\n  console.log(err, response)\n})\n\napi.request('/store/post', {\n  method: 'POST',\n  body: 'My new Post!'\n}, (err, response) =\u003e {\n  console.log(err, response)\n})\n\n/* Promises */\n\napi.request('/posts/1')\n.then((response) =\u003e {\n  console.log(response)\n})\n.catch((err) =\u003e {\n  console.log(err)\n})\n\napi.request('/store/post', {\n  method: 'POST',\n  body: 'My new Post!'\n})\n.then((response) =\u003e {\n  console.log(response)\n})\n.catch((err) =\u003e {\n  console.log(err)\n})\n```\n\n---\n\n## Setup / Install\n\nUse `npm install @burnett01/extended-request` \n\n```javascript\n// ES6\nimport ExtendedRequest from '@burnett01/extended-request'\n\n// ES5\nvar ExtendedRequest = require('@burnett01/extended-request')\n```\n\n---\n\n## Build\n\n### NPM\n\n```npm run build```\n\n### Make\n\n```make build```\n\n---\n\n## Unit-Tests\n\nThe testing-framework used by this module is [Mocha](https://github.com/mochajs/mocha) with the BDD / TDD assertion library [Chai](https://github.com/chaijs/chai).\n\n* test/test.default.js `Performs 9 tests` | [Source](../master/test/test.default.js)\n\nDefault reporter: `list`\n\n### Make\n\n```make test```\n\n### NPM\n\n```npm test```\n\n---\n\n## Contributing\n\nYou're very welcome and free to contribute. Thank you.\n\n---\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fextended-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburnett01%2Fextended-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburnett01%2Fextended-request/lists"}