{"name":"centra","version":"2.6.0","description":"The core lightweight HTTP client for Node","main":"createRequest.js","scripts":{"test":"node test.js","prepublishOnly":"npm test"},"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":{"retra":"^1.0.2","whew":"^1.1.3"},"gitHead":"5f1578a8ad5e982b7e57582eb1ee86bcdd1499e4","_id":"centra@2.6.0","_nodeVersion":"19.0.1","_npmVersion":"9.1.1","dist":{"integrity":"sha512-dgh+YleemrT8u85QL11Z6tYhegAs3MMxsaWAq/oXeAmYJ7VxL3SI9TZtnfaEvNDMAPolj25FXIb3S+HCI4wQaQ==","shasum":"79117998ee6908642258db263871381aa5d1204a","tarball":"http://registry-npm.ywwl.com/centra/download/centra-2.6.0.tgz","fileCount":7,"unpackedSize":10190,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAlKn20B0znIbATBGTol8r9iPf4y3ROYjxff/jD+EtQJAiA5Zk3AqiKYiiz1lT7bG9DeDAevC/UKWF5iogX+y+72FA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjeUNSACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrb/A//Y9Ic35GVp6GvBFgpVEe8lWmyxT0SOf06n3it8XRMkaunLQYh\r\nZ054k/oSdvQ3loYTelUedtrjeSsSxajOjA/nnweqmiLjI9ehME6Bu/5PhrH3\r\n8OGqydMGTb3oqbj+abU1ni99pV9vPTF1pHh+44MtaTFuUU65bDGOin/KZEho\r\nA3c7RYN3EZhHj78eMnbevU66kB9/5Zdjv8dPaxmMet5nAJqC/BSprbcGRdBf\r\nvtmMDpmswdJdHVIULuojQ+9ywdOVHZ0EcRItW3C97bGonYOgob2iMAjpPjpX\r\nuecVbchTemhG6qAX/LSK3scy5LecxpmVbs8+4l/nkwRH0zYEclvlYW7C0lD6\r\nRkTG8+2wPNI8bccernnR669Q6O9V+VhqRB5sW4MhnbH4pwgKiSwc9Wd53s03\r\nz3G20Fgkzu1gxZBca+V5gWwQDhiFYP9u+xaWi2R3Q0sNjNVmLIvckQYMaef3\r\nG09dlWw8wMpzty7WJQ0FGZ6oLQoGaZJq9QkoKC2+q02cJHvGmCGLBwK0vkGw\r\nokfJ5U9Br6lGT0dOSWk4KnhEvDKigMe994QNuf3ZBVGHYLB/O7/eW2/dnmQz\r\nVPzjTbef3zuvm4rsiKvh1Hs/5sPQFnVD8jq6S+gn5fBz6clvMBNBILT9P8sB\r\numuaWFP8Lulhy3H23UZdzNyYpK4MuK6IKmU=\r\n=lOGO\r\n-----END PGP SIGNATURE-----\r\n","size":4098,"noattachment":false,"key":"/centra/-/centra-2.6.0.tgz"},"_npmUser":{"name":"ethan_","email":"futuristiccake@gmail.com"},"directories":{},"maintainers":[{"name":"ethan_","email":"futuristiccake@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/centra_2.6.0_1668891474800_0.3266686990546539"},"_hasShrinkwrap":false,"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://example.com').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://example.com').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://example.com').stream().send().then((stream) => stream.pipe(fs.createWriteStream(path.join(__dirname, 'logo.png'))))\n```\n\n### Follow redirects\n\n```js\nc('https://example.com/').followRedirects(5).send()\n```\n\n### Switch paths on the fly\n\n```js\nc('https://example.com/test').path('/hello').send()\n\n// This will make a request to https://example.com/test/hello\n```\n\n### Specify request headers\n\nOne at a time:\n\n```js\nc('https://example.com').header('Content-Type', 'application/json').send()\n```\n\nMany at a time:\n\n```js\nc('https://example.com').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://example.com').option('localAddress', '127.0.0.2').send()\n```\n\n### Accept compressed responses\n\n```js\nc('https://example.com').compress().send()\n\n// This will cause centra to accept compressed content from the server. (gzip and deflate are currently supported)\n```\n","publish_time":1668891474961,"_cnpm_publish_time":1668891474961,"dist-tags":{"latest":"2.7.0"}}