{"_id":"@awenk/http-helper-api","_rev":"3-763d0ed033bc60e6191613eabd4671a8","name":"@awenk/http-helper-api","dist-tags":{"latest":"1.5.1"},"versions":{"1.0.0":{"name":"@awenk/http-helper-api","version":"1.0.0","keywords":["http","request","fetch","nodejs","stream","axios","helper"],"author":{"name":"Awenk"},"license":"MIT","_id":"@awenk/http-helper-api@1.0.0","maintainers":[{"name":"awenks","email":"badueny@gmail.com"}],"homepage":"https://github.com/awenk/http-helper-api#readme","bugs":{"url":"https://github.com/awenk/http-helper-api/issues"},"dist":{"shasum":"d12fa8685ecf2e06e10587849a13e913f87d9319","tarball":"https://registry.npmjs.org/@awenk/http-helper-api/-/http-helper-api-1.0.0.tgz","fileCount":6,"integrity":"sha512-iGBtoAbDKwc0mPjabEm+lPllsG+ywdNx/bZ6YB58yNBBnWXNVZpom7nqCFqiLq5NUMmaCpml7Kk/r3JduPoihA==","signatures":[{"sig":"MEYCIQClbpOrKOE9gV2KivDz4pXilfqgeba+wJmlhcfMGTDnUQIhAJ+deXFy6g+yxOVcV9ug5epxwVSuaCsBsYyOVg40zyC2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13352},"main":"index.js","type":"commonjs","gitHead":"fbd0e770d38ab7543d3c5342a56604ecb0d3de11","scripts":{"test":"node test/request.test.js"},"_npmUser":{"name":"awenks","email":"badueny@gmail.com"},"repository":{"url":"git+https://github.com/awenk/http-helper-api.git","type":"git"},"_npmVersion":"11.6.1","description":"Minimal HTTP helper untuk GET/POST, query, buffer, streaming, auto file download","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-helper-api_1.0.0_1760369346486_0.051240854594295504","host":"s3://npm-registry-packages-npm-production"}},"1.5.0":{"name":"@awenk/http-helper-api","version":"1.5.0","keywords":["http","request","fetch","nodejs","stream","axios","helper"],"author":{"name":"Awenk"},"license":"MIT","_id":"@awenk/http-helper-api@1.5.0","maintainers":[{"name":"awenks","email":"badueny@gmail.com"}],"homepage":"https://github.com/awenk/http-helper-api#readme","bugs":{"url":"https://github.com/awenk/http-helper-api/issues"},"dist":{"shasum":"f63ef5b604495df29fef84523b282eef1ed459d9","tarball":"https://registry.npmjs.org/@awenk/http-helper-api/-/http-helper-api-1.5.0.tgz","fileCount":6,"integrity":"sha512-KeKqkNE7BZRNmnZe32H8c5soYLevS8eAR4wvDEbrKtQqhA2rq4yfez297Oq5oIitkURGn/Ae1IKeKW03vwiy7g==","signatures":[{"sig":"MEQCIGCMUlkoYrQPbrzDMuACF2MQ7q0JU6ytQ/m9fVcBfGuWAiAC3l7E7RpMvxmrlnUevkkzzK4b6n6smTsbHbnc+krEtA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13461},"main":"index.js","type":"commonjs","gitHead":"fbd0e770d38ab7543d3c5342a56604ecb0d3de11","scripts":{"test":"node test/request.test.js"},"_npmUser":{"name":"awenks","email":"badueny@gmail.com"},"repository":{"url":"git+https://github.com/awenk/http-helper-api.git","type":"git"},"_npmVersion":"11.6.1","description":"Minimal HTTP helper untuk GET/POST, query, buffer, streaming, auto file download","directories":{},"_nodeVersion":"22.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-helper-api_1.5.0_1760369632379_0.4788584407391163","host":"s3://npm-registry-packages-npm-production"}},"1.5.1":{"name":"@awenk/http-helper-api","version":"1.5.1","description":"Minimal HTTP helper untuk GET/POST, query, buffer, streaming, auto file download","main":"index.js","scripts":{"test":"node test/request.test.js"},"type":"commonjs","keywords":["http","request","fetch","nodejs","stream","axios","helper"],"author":{"name":"Awenk"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/awenk/http-helper-api.git"},"publishConfig":{"access":"public"},"gitHead":"417fe0f7cf190a877cf3c20fb4374ee437c66bc0","_id":"@awenk/http-helper-api@1.5.1","bugs":{"url":"https://github.com/awenk/http-helper-api/issues"},"homepage":"https://github.com/awenk/http-helper-api#readme","_nodeVersion":"22.14.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-5Ld/JOKbaQyexMEk3EPy55JmY0jVWUooUgXEnk6e/j4pgyCBitsytzsyhtjWe632ZJU9fKRBFD52geigFwRWIg==","shasum":"e6922f51a0d975858e2ab6afde5360428c4f0316","tarball":"https://registry.npmjs.org/@awenk/http-helper-api/-/http-helper-api-1.5.1.tgz","fileCount":6,"unpackedSize":13469,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFdhhm1xTRxDrd2s5D61jrXN9JVIbrtxsM0+1lgeza9AAiEAlf2x8rYNl/1HUgUukdyxeLzvdYqVHw0sRFh0KUw/2Ow="}]},"_npmUser":{"name":"awenks","email":"badueny@gmail.com"},"directories":{},"maintainers":[{"name":"awenks","email":"badueny@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-helper-api_1.5.1_1760369948562_0.9697717495110643"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-13T15:29:06.395Z","modified":"2025-10-13T15:39:08.962Z","1.0.0":"2025-10-13T15:29:06.672Z","1.5.0":"2025-10-13T15:33:52.563Z","1.5.1":"2025-10-13T15:39:08.743Z"},"bugs":{"url":"https://github.com/awenk/http-helper-api/issues"},"author":{"name":"Awenk"},"license":"MIT","homepage":"https://github.com/awenk/http-helper-api#readme","keywords":["http","request","fetch","nodejs","stream","axios","helper"],"repository":{"type":"git","url":"git+https://github.com/awenk/http-helper-api.git"},"description":"Minimal HTTP helper untuk GET/POST, query, buffer, streaming, auto file download","maintainers":[{"name":"awenks","email":"badueny@gmail.com"}],"readme":"# http-helper-api Node.js\r\n\r\nMinimalis dan fleksibel: helper HTTP untuk Node.js tanpa dependency eksternal.  \r\nMendukung semua kebutuhan umum request — mirip `axios`, tapi jauh lebih ringan.\r\n\r\n---\r\n\r\n## 🚀 Fitur Utama\r\n\r\n- ✅ Mendukung semua method: `GET`, `POST`, `PUT`, `DELETE`, dll\r\n- ✅ Support full URL atau `{ hostname, path }`\r\n- ✅ Auto handle `query: {}` → ?key=value\r\n- ✅ Body support: `JSON`, `form-urlencoded`\r\n- ✅ Otomatis parsing JSON berdasarkan Content-Type\r\n- ✅ `onlyBody: true` → langsung dapat isi response\r\n- ✅ `responseType: 'buffer'` untuk download file (image, PDF, ZIP, dll)\r\n- ✅ `requestStream()` → untuk streaming besar seperti video / download\r\n- ✅ `outputFile` → auto simpan file ke disk\r\n- ✅ `timeout`, `rejectUnauthorized`, dan headers custom\r\n\r\n---\r\n\r\n---\r\n\r\n## 🧾 List Opsi\r\n| Opsi                 | Tipe            | Keterangan                                       |\r\n| -------------------- | --------------- | ------------------------------------------------ |\r\n| `method`             | `string`        | HTTP method: `GET`, `POST`, dll *(default: GET)* |\r\n| `headers`            | `object`        | Header custom, contoh `Content-Type`             |\r\n| `body`               | `object/string` | Data yang dikirim (otomatis encode)              |\r\n| `query`              | `object`        | Akan diubah ke `?a=1&b=2` otomatis               |\r\n| `onlyBody`           | `boolean`       | Kalau `true`, langsung return `body`             |\r\n| `responseType`       | `string`        | Bisa: `buffer`, `text`, `auto` *(default)*       |\r\n| `rejectUnauthorized` | `boolean`       | Skip SSL check (gunakan hanya untuk testing!)    |\r\n| `timeout`            | `number`        | Timeout dalam ms *(default: 10000)*              |\r\n| `outputFile`         | `string`        | Path ke file (digunakan di `requestStream`)      |\r\n\r\n---\r\n\r\n##📚  Penggunaan\r\n\r\n🔹 request(url, options)<br>\r\nKirim request dan dapatkan { `statusCode`, `headers`, `body` }.\r\n```js\r\nconst { request } = require('@awenk/http-helper-api');\r\n\r\nconst res = await request('https://api.example.com/data', {\r\n  method: 'POST',\r\n  headers: { 'Content-Type': 'application/json' },\r\n  body: { user: 'awenk' },\r\n  query: { lang: 'id' }\r\n});\r\n\r\nconsole.log(res.statusCode); // 200\r\nconsole.log(res.body);       // object hasil JSON\r\n```\r\n🔹 requestBodyOnly(url, options)<br>\r\nLangsung dapat isi body saja dari response.\r\n```js\r\nconst { requestBodyOnly } = require('@awenk/http-helper-api');\r\n\r\nconst data = await requestBodyOnly('https://api.example.com/info', {\r\n  query: { year: 2025 }\r\n});\r\n\r\nconsole.log(data); // langsung object / array / string\r\n```\r\n🔹 requestStream(url, options)<br>\r\nKembalikan readable stream (untuk file besar) atau langsung simpan ke file jika outputFile diberikan.\r\n```js\r\nconst fs = require('fs');\r\nconst { requestStream } = require('@awenk/http-helper-api');\r\n\r\n// Pipe ke file manual\r\nconst stream = await requestStream('https://example.com/file.pdf');\r\nstream.pipe(fs.createWriteStream('output.pdf'));\r\n\r\n// Auto save ke disk\r\nawait requestStream('https://example.com/image.jpg', {\r\n  outputFile: 'downloaded.jpg'\r\n});\r\n```\r\n\r\n📦 Contoh: Download File sebagai Buffer\r\n```js\r\nconst fs = require('fs');\r\nconst { requestBodyOnly } = require('@awenk/http-helper-api');\r\n\r\nconst buffer = await requestBodyOnly('https://example.com/file.pdf', {\r\n  responseType: 'buffer'\r\n});\r\n\r\nfs.writeFileSync('file.pdf', buffer);\r\n```\r\n\r\n📦 Contoh: Proxy Stream ke Response Express\r\n```js\r\nconst express = require('express');\r\nconst { requestStream } = require('@awenk/http-helper-api');\r\n\r\nconst app = express();\r\n\r\napp.get('/proxy-pdf', async (req, res) => {\r\n  const stream = await requestStream('https://example.com/file.pdf');\r\n  res.setHeader('Content-Type', 'application/pdf');\r\n  stream.pipe(res);\r\n});\r\n```\r\n---\r\n\r\n## 📦 Instalasi\r\n\r\n```bash\r\nnpm install github:badueny/http-helper-api\r\n```\r\nAtau\r\n```bash\r\nnpm install git+https://github.com/badueny/http-helper-api.git\r\n```\r\nAtau\r\n```bash\r\nnpm i @awenk/http-helper-api\r\n```\r\n\r\n---\r\n\r\n![Node.js CI](https://github.com/badueny/http-helper-api/actions/workflows/node-ci.yml/badge.svg)\r\n\r\n🛠 Dibuat di 📍 Indonesia\r\n📄 Lisensi\r\nMIT License — bebas digunakan dan dimodifikasi.\r\n\r\n\r\n","readmeFilename":"README.md"}