{"_id":"@build-from-bits/cdn-connections","name":"@build-from-bits/cdn-connections","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@build-from-bits/cdn-connections","version":"1.0.0","description":"Client library for interacting with the Chandrila CDN Server.","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts --format esm,cjs --dts --clean --external axios","dev":"tsup src/index.ts --format esm,cjs --dts --watch --external axios","lint":"eslint . --ext .ts","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","pack:check":"npm pack --dry-run","publish:npm":"npm publish --access public","publish:github":"npm publish --registry https://npm.pkg.github.com","publish:gitlab":"npm publish"},"keywords":["cdn","axios","upload"],"license":"Apache-2.0","publishConfig":{"access":"public"},"dependencies":{"axios":"^1.7.9"},"devDependencies":{"eslint":"^9.17.0","tsup":"^8.3.5","typescript":"^5.7.2","typescript-eslint":"^8.18.0","vitest":"^3.0.0"},"gitHead":"1f26986718f2e33b53a485573c66dd8a3653c3b9","_id":"@build-from-bits/cdn-connections@1.0.0","_nodeVersion":"26.4.0","_npmVersion":"11.18.0","dist":{"integrity":"sha512-wsMYm2yg4BU4iBkWsVLvgT9Jov/0uxpEjpVxuQYrZoBB4EYHx1dvg94MbKSHOGGw7RmqqFeF/E7mJceuLU+f0g==","shasum":"225115e9a900c3008048ae6525a5b1410ee510cc","tarball":"https://registry.npmjs.org/@build-from-bits/cdn-connections/-/cdn-connections-1.0.0.tgz","fileCount":7,"unpackedSize":29262,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGJw4LaZ7fVeBYv+8HjuV0UKVUheHuXiKZgBOTKMPZCQAiEAsQdvsvmRtC3xsZv3+Jvy2GqUBS8dW3vba5k8cGpxjM8="}]},"_npmUser":{"name":"bb_tech","email":"tech@buildfrombits.com"},"directories":{},"maintainers":[{"name":"bb_tech","email":"tech@buildfrombits.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cdn-connections_1.0.0_1786603948581_0.06094371523604103"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-13T06:52:28.404Z","1.0.0":"2026-08-13T06:52:28.814Z","modified":"2026-08-13T06:52:29.019Z"},"maintainers":[{"name":"bb_tech","email":"tech@buildfrombits.com"}],"description":"Client library for interacting with the Chandrila CDN Server.","keywords":["cdn","axios","upload"],"license":"Apache-2.0","readme":"# @build-from-bits/cdn-connections\n\nClient library for interacting with the Chandrila CDN Server.\n\nFeatures:\n- `saveFile` with a **parameterized upload field name** (default `file_to_upload`)\n- `getFileUrl` / `getVideoStreamUrl` with **URL-encoded keys**\n- `getVideoUrl` for pre-signed video URLs\n- optional **auth/API-key header hook** for upload/read requests\n\n## Installation\n\n```bash\nnpm install @build-from-bits/cdn-connections\n```\n\n## Usage\n\n```javascript\nimport { createCdnSystem } from '@build-from-bits/cdn-connections';\n\n// Initialize the CDN system\nconst cdnSystem = createCdnSystem({\n  baseUrl: 'http://localhost:8000', // URL of your Chandrila CDN server\n});\n\n// Access the file service\nconst { fileService } = cdnSystem;\n\n// 1. Upload a file\nconst uploadResponse = await fileService.saveFile(myFileObject);\nconsole.log('Uploaded File Key:', uploadResponse.file_id); // Returns the file ID/Key\n\n// 2. Get an image URL (with optional resizing/quality/format)\nconst imageUrl = fileService.getFileUrl('my-image-key', { w: 800, q: 80, f: 'webp' });\n// Result: http://localhost:8000/api/file/get?key=my-image-key&w=800&f=webp&q=80\n\n// 3. Get a streaming video URL\nconst videoUrl = fileService.getVideoStreamUrl('my-video-key');\n\n// 4. Get a presigned URL for a video\nconst presigned = await fileService.getVideoUrl('my-video-key');\n```\n\n## Custom Upload Field Name\n\nApps that send a different form field can override it via `configOverrides`:\n\n```javascript\nconst cdnSystem = createCdnSystem({\n  baseUrl: 'http://localhost:8000',\n  configOverrides: {\n    uploadFieldName: 'media_file',\n  },\n});\n```\n\n## Auth / API-key Headers\n\nPass a `headerHook` to inject `api-key`/`api-secret` (or any headers) on every CDN request. It may be async and receives the axios request config:\n\n```javascript\nconst cdnSystem = createCdnSystem({\n  baseUrl: 'http://localhost:8000',\n  headerHook: async (request) => ({\n    'api-key': import.meta.env.VITE_API_KEY,\n    'api-secret': import.meta.env.VITE_API_SECRET_KEY,\n  }),\n});\n```\n\n## Environment Variables\n\n`baseUrl` is resolved (in priority order) from `VITE_CDN_BASE_URL`, `REACT_APP_CDN_BASE_URL`, `CDN_BASE_URL`, or the `baseUrl` argument.\n\n## Publish\n\n```bash\nnpm run pack:check\nnpm run publish:npm\nnpm run publish:github\n```\n\n## License\n\nLicensed under the Apache License 2.0.\n\nCopyright 2026 Build From Bits Pvt Ltd.\n","readmeFilename":"README.md","_rev":"1-a76e2fb9163adc7b048c3c40297e5952"}