{"_id":"@aeru/centra","_rev":"2-04a5eb34414301b336e0351ba4a31f4b","name":"@aeru/centra","dist-tags":{"latest":"1.0.6"},"versions":{"2.5.0":{"name":"@aeru/centra","version":"2.5.0","description":"The core lightweight HTTP client for Node","main":"createRequest.js","repository":{"type":"git","url":"git+https://github.com/ethanent/centra.git"},"keywords":["http","https","request","fetch","url","lightweight"],"author":{"name":"Ethan Davis","url":"https://ethanent.me"},"license":"MIT","bugs":{"url":"https://github.com/ethanent/centra/issues"},"homepage":"https://github.com/ethanent/centra","devDependencies":{"whew":"^1.1.3"},"gitHead":"92fc2a6d6d0cb357b830f9f831002992558bcfbe","_id":"@aeru/centra@2.5.0","_nodeVersion":"15.14.0","_npmVersion":"7.13.0","dist":{"integrity":"sha512-vWmvqpJc6xSprPOGcFGBtG2TIboPLHMtE3WZAkXLPW8FHD09YIB/nAYjrUy1ScVB7qTZSud11+ABh5GQeyNu2g==","shasum":"88c14e4d26a45cbb376e55b289c06b7be057ef7b","tarball":"https://registry.npmjs.org/@aeru/centra/-/centra-2.5.0.tgz","fileCount":8,"unpackedSize":11610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhGfAwCRA9TVsSAnZWagAAL6EP/3+cajk/OA3tzZYDMjDV\nLfKexJyaBQqzzFQVuB7f9OylHTnlQ+YBEn7URp+forqjO5XTAznxAsDQ+xQt\nydH3jxFZcRD/BJ6bzCQhVg6/zXnXYo5+gz27TDt+jrVGPxAKVDJeHPX3i/CZ\nX2frxvUkxlzDO7/7q+MgeomBbIZACgWwfiaV0uYFIoDJnIADgRkBSWaAZlVZ\njPvNfZg8lzhV2jtx2XCwWntgc+q4ljFSt94nVPQHv4oyV5XHGAnGIqkWukly\nPV6MmKwdrIMRftIivqMPP/aYauoCVDN9eoRGPP6K8/oLfKi0vdyYNr+Xe7V9\nCiNjPUdr3PBzK2U3QJ10X/z9h6zhimLwjBz3W6JXpf20cXoIbqemQhvhwD8K\nt9g82e4lp8FZSob6oCxuXIVvEm2esv31vngLxF/uhyjYlQFtkkHZU3x2UJ0M\neSCxfbhPrWQMlrjaKq2GYT1xLAKOlnMThN4QlLsAVc37cgsi8j+5hyuYVDQ7\nHpFu5s9ZGbUqHnkGj3vaQt3zTzcWBpyCBfkVurw/OaxekjBX2yBl0+G1GMlA\nXu2zqyPpEbzVDjZrprDfZ5I7ULqCR324TZhK7rKdd5u/NZblgc5Ip4CCgVMs\nNbt7ZfMUtzsJl5hmIaHtxuYNIfi9GO0WYtMlTEnCCEKTCCOUk8u5jhkB4xbw\n5e8B\r\n=QeLn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxFrAdxtXMrR8JfqlZ5rqAeQYH8qpuVnl4YpXnbRjB5wIgOB9BGuKal5SqAMNT9/WJBRJTzFVA7wH6NYOfit+7Gwk="}]},"_npmUser":{"name":"aeru","email":"sikeki7324@cfcjy.com"},"directories":{},"maintainers":[{"name":"aeru","email":"sikeki7324@cfcjy.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/centra_2.5.0_1629089840691_0.7363164700322553"},"_hasShrinkwrap":false},"1.0.6":{"name":"@aeru/centra","version":"1.0.6","description":"The core lightweight HTTP client for Node","main":"createRequest.js","repository":{"type":"git","url":"git+https://github.com/ethanent/centra.git"},"keywords":["http","https","request","fetch","url","lightweight"],"author":{"name":"Ethan Davis","url":"https://ethanent.me"},"license":"MIT","bugs":{"url":"https://github.com/ethanent/centra/issues"},"homepage":"https://github.com/ethanent/centra","devDependencies":{"whew":"^1.1.3"},"gitHead":"92fc2a6d6d0cb357b830f9f831002992558bcfbe","_id":"@aeru/centra@1.0.6","_nodeVersion":"15.14.0","_npmVersion":"7.13.0","dist":{"integrity":"sha512-IinbO1tbaMM/x5UWkoldd7nGj/f2G1N0n1z2kaXn9h5/RBy+xnhGhTKAAqHf0wjxz5kyHKd/AIK1HuLocF0NQw==","shasum":"45bcc53ccaf988ac4804998384d8d51a5e183bc6","tarball":"https://registry.npmjs.org/@aeru/centra/-/centra-1.0.6.tgz","fileCount":8,"unpackedSize":11610,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhGfE2CRA9TVsSAnZWagAArN0P/09IhBSn8UFdntrjTT7T\nnisL7WWJqlH19TdKgXatNRM3JbEogqq/vLBDcFDsvsTEXm6Sdwi/L8H3/3Nn\nnWz7iTpyjAuH0AZgvh4qKK8/Bvm2pqs+6fknXHzG5ddX1JZVT/nAaaKCL4mh\naoH46xE6gaaqTK2wcFjJI/4tIWhWA8X6rzShSBNSDd4SPVaWCii7TykE/Bhv\nDmbDPqxVsZ/NAisIIGI84eB9DV9311CeceXjSJJNL+rdd/ceRvXr9UOH8ZkK\n60b2R6VnQy9/1T2IQR6UNMNXOXri5dNZhGUvuVPUDo9Po1gf7eDv1i7Dsl8e\nGY3lDqNgFiOuz/ajhMs5MGE0yrvEQWLWnSRXHLpHyWoY99lNXwWOHQtzuRcK\nfomh61ooDFtYECO6lnoGznMs0I7tP6cKsHQ+CumHSsuzXJaZUFubVwduqHHM\nBl7jnziZpnzIEDJl3aScGi1ikwuELKZdbtP9WQKPlolM6bJCaO4axXJyw61y\nVo2t6gpqFuY+0gF353+B5AZuuWZmVu7GEsfHBE4SItX/7d43udK7Arm3UW6f\nnZD9/QfGrS1l3YabSNpU5vBA+9RVzUCbYH0BrinX+Jla6ES54OwFi10ngJFM\nd76qFzUn9udWj4WmhANZTo6cU3oH61r1EiOIeg7wqCICOVzi2JYqp5rUVBVx\nASJb\r\n=M6ox\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBEf60WaQh8UhcTNYvGmFM7MpAgb8gU9IJ6CggVc4e4jAiBaTuvEzDVnnFu+pKX+27dMZB0Ilq4bKIZ8aqqzc8RT7g=="}]},"_npmUser":{"name":"aeru","email":"sikeki7324@cfcjy.com"},"directories":{},"maintainers":[{"name":"aeru","email":"sikeki7324@cfcjy.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/centra_1.0.6_1629090102366_0.2214358732853805"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-16T04:57:20.641Z","2.5.0":"2021-08-16T04:57:20.842Z","modified":"2022-04-04T11:49:31.772Z","1.0.6":"2021-08-16T05:01:42.513Z"},"maintainers":[{"name":"aeru","email":"sikeki7324@cfcjy.com"}],"description":"The core lightweight HTTP client for Node","homepage":"https://github.com/ethanent/centra","keywords":["http","https","request","fetch","url","lightweight"],"repository":{"type":"git","url":"git+https://github.com/ethanent/centra.git"},"author":{"name":"Ethan Davis","url":"https://ethanent.me"},"bugs":{"url":"https://github.com/ethanent/centra/issues"},"license":"MIT","readme":"<p align=\"center\" style=\"text-align: center;\"><img src=\"https://github.com/ethanent/centra/blob/master/media/centraLogo.png?raw=true\" width=\"400\"/></p>\n\n> The core lightweight HTTP client for Node\n\n[GitHub](https://github.com/ethanent/centra) | [NPM](https://npmjs.com/package/centra)\n\n## Install\n\n```shell\nnpm i centra\n```\n\n## Why centra?\n\ncentra is the best request library for developers; it provides a number of extremely useful features while still being one of the most lightweight Node.js HTTP client libraries available.\n\n## Use centra!\n\nFirst, require the library.\n\n```js\nconst c = require('centra')\n```\n\nThen let's make a request in an async function!\n\n```js\n;(async () => {\n\tconst res = await c('https://ethanent.me').send()\n\n\tconsole.log(await res.text())\n})()\n```\n\n## More advanced usage\n\n### Send data in a JSON body\n\n```js\nc('https://example.com/nonexistentJSONAPI', 'POST').body({\n\t'name': 'Ethan'\n}, 'json').send().then((res) => {\n\t/*...*/\n})\n```\n\n### Send data in a form body\n\n```js\nc('https://example.com/nonexistentJSONAPI', 'POST').body({\n\t'name': 'Ethan'\n}, 'form').send().then((res) => {\n\t/*...*/\n})\n```\n\n### Set query string parameters\n\nOne at a time:\n\n```js\nc('https://example.com/user').query('id', 'u1817760').send().then((res) => {\n\t/*...*/\n})\n```\n\nMany at a time:\n\n```js\nc('https://example.com/user').query({\n\t'id', 'u1817760',\n\t'name': 'Ethan'\n}).send().then((res) => {\n\t/*...*/\n})\n```\n\n### Set a request timeout\n\n```js\nc('https://ethanent.me').timeout(2000).send().then((res) => {\n\t// Success!\n}).catch((err) => {\n\t// Has the request timed out?\n})\n```\n\n### Stream a request's response\n\nIn this example, the [stream](https://nodejs.org/api/stream.html) is piped to a file:\n\n```js\n// require the fs module beforehand\n\nc('https://ethanent.me/images/mainLogo.png').stream().send().then((stream) => stream.pipe(fs.createWriteStream(path.join(__dirname, 'logo.png'))))\n```\n\n### Switch paths on the fly\n\n```js\nc('https://ethanent.me/test').path('/hello').send()\n\n// This will make a request to https://ethanent.me/test/hello\n```\n\n### Specify request headers\n\nOne at a time:\n\n```js\nc('https://ethanent.me').header('Content-Type', 'application/json').send()\n```\n\nMany at a time:\n\n```js\nc('https://ethanent.me').header({\n\t'Content-Type': 'application/json',\n\t'X-Connecting-With': 'centra'\n}).send()\n```\n\n### Modify core HTTP request options\n\nSee [http.request](https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_http_request_url_options_callback)'s options for more information about core HTTP request options.\nLet's change our localAddress as an example.\n\n```js\nc('https://ethanent.me').option('localAddress', '127.0.0.2').send()\n```\n\n### Accept compressed responses\n\n```js\nc('https://ethanent.me').compress().send()\n\n// This will cause centra to accept compressed content from the server. (gzip and deflate are currently supported)\n```","readmeFilename":"README.md"}