{"_id":"@devstorage/node","name":"@devstorage/node","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@devstorage/node","version":"0.1.0","description":"Official DevStorage SDK for Node.js, browsers, and edge runtimes.","license":"MIT","author":{"name":"DevStorage"},"homepage":"https://devstorage.io","repository":{"type":"git","url":"git+https://github.com/chiranjeebhub/devstorage.git","directory":"packages/node"},"bugs":{"url":"https://github.com/chiranjeebhub/devstorage/issues"},"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","dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run"},"engines":{"node":">=18"},"keywords":["devstorage","storage","upload","r2","cloudflare","sdk"],"devDependencies":{"@types/node":"^20.0.0","tsup":"^8.0.0","typescript":"^5.0.0","vitest":"^4.1.9"},"publishConfig":{"access":"public"},"_id":"@devstorage/node@0.1.0","gitHead":"a04cb190f82915a586df4bb39e72fb7d050c0960","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-NzyqG+qo2xT4SjEM8W+41xc6P64QlWsbZ8GyyC8Mhtx3D6F7Auyf5e1qUS4ciBncw0QxFs1eKF9aKIHyP1KiNA==","shasum":"32ed4dce19f50b4e55f1859e543fb9635fe601cd","tarball":"https://registry.npmjs.org/@devstorage/node/-/node-0.1.0.tgz","fileCount":8,"unpackedSize":53317,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDJnIajoEVxcJPzydvsyMwTSjr0LaVCgVAa3QzM50V1JAiEAn7T3WL2aY9mvL4P3wLr+15yi6eMBGssvB7Zs07v96do="}]},"_npmUser":{"name":"devstorage","email":"work.chiranjeeb@gmail.com"},"directories":{},"maintainers":[{"name":"devstorage","email":"work.chiranjeeb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/node_0.1.0_1782933206647_0.376820143518112"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-01T19:13:26.470Z","0.1.0":"2026-07-01T19:13:26.801Z","modified":"2026-07-01T19:13:27.024Z"},"maintainers":[{"name":"devstorage","email":"work.chiranjeeb@gmail.com"}],"description":"Official DevStorage SDK for Node.js, browsers, and edge runtimes.","homepage":"https://devstorage.io","keywords":["devstorage","storage","upload","r2","cloudflare","sdk"],"repository":{"type":"git","url":"git+https://github.com/chiranjeebhub/devstorage.git","directory":"packages/node"},"author":{"name":"DevStorage"},"bugs":{"url":"https://github.com/chiranjeebhub/devstorage/issues"},"license":"MIT","readme":"# @devstorage/node\n\nOfficial DevStorage SDK. Works in Node.js 18+, browsers, and edge runtimes.\n\n```bash\nnpm install @devstorage/node\n```\n\n## Quick start\n\n```ts\nimport { DevStorage } from \"@devstorage/node\";\nimport { readFile } from \"node:fs/promises\";\n\nconst ds = new DevStorage({\n  apiKey: process.env.DSK_API_KEY!,\n});\n\nconst buffer = await readFile(\"./photo.jpg\");\n\nconst file = await ds.upload(buffer, {\n  name: \"photo.jpg\",\n  mimeType: \"image/jpeg\",\n  metadata: { orderId: \"ord_123\" },\n});\n\nconsole.log(file.url); // presigned R2 URL\nconsole.log(file.id);  // \"fil_01HXYZ...\"\n```\n\n## API\n\n### `new DevStorage(options)`\n\n| Option    | Type                | Description                                                          |\n| --------- | ------------------- | -------------------------------------------------------------------- |\n| `apiKey`  | `string` (required) | Project API key (`dsk_live_...`) from your dashboard.                |\n| `baseUrl` | `string`            | Override the API host. Defaults to `https://api.devstorage.io`.     |\n| `fetch`   | `typeof fetch`      | Inject a custom fetch implementation (useful for tests).             |\n\n### `ds.upload(body, options) → Promise<UploadedFile>`\n\nUploads a file directly to Cloudflare R2 via a presigned URL, then confirms the upload server-side.\n\n`body` accepts `Buffer`, `Uint8Array`, `ArrayBuffer`, or `Blob`.\n\n| Option     | Type                       | Description                                                  |\n| ---------- | -------------------------- | ------------------------------------------------------------ |\n| `name`     | `string` (required)        | File name shown in your dashboard.                           |\n| `mimeType` | `string` (required)        | Content type sent to R2 and recorded against the file.       |\n| `metadata` | `Record<string, string>`   | Arbitrary key/value pairs returned with the file.            |\n| `signal`   | `AbortSignal`              | Cancel the upload (and the underlying PUT) at any point.     |\n\nIf the PUT to R2 fails the SDK calls `/v1/upload/abort` for you before throwing.\n\n### `ds.files.list(options?) → Promise<{ files, nextCursor, hasMore }>`\n\nCursor-paginated. Pass the previous response's `nextCursor` to fetch the next page.\n\n### `ds.files.get(id) → Promise<FileRecord>`\n\nReturns the file metadata plus a fresh presigned `url`.\n\n### `ds.files.delete(id) → Promise<void>`\n\nRemoves the file from R2 and decrements your storage usage.\n\n## Errors\n\nAll non-2xx API responses throw `DevStorageError`:\n\n```ts\nimport { DevStorage, DevStorageError } from \"@devstorage/node\";\n\ntry {\n  await ds.upload(buf, { name: \"x\", mimeType: \"image/png\" });\n} catch (err) {\n  if (err instanceof DevStorageError) {\n    console.error(err.status, err.message);\n  }\n}\n```\n","readmeFilename":"README.md","_rev":"1-c95f86fad7414c5329d8b901bbcc8cfa"}