SDK
The official TypeScript client for the Gigadrive Network API, running on Node.js, in browsers, and on edge runtimes.
@gigadrive/sdk is the TypeScript client for the Gigadrive Network API. Use it when your code has to call that API: a deployed Function reading its own bucket, a CI job triggering a deployment, or a browser sending a file straight to storage.
Install
npm install @gigadrive/sdkThe package ships CommonJS and ESM builds with bundled type declarations, so require and import both work and there is no separate @types package to add. It pulls in tus-js-client, which drives resumable uploads.
Supported runtimes
Anything with a global fetch: Node.js 18 or newer, browsers, and edge runtimes.
Two upload sources are Node-only, because they read from the filesystem:
| Source | Outside Node |
|---|---|
upload({ path }) | throws Uploading from a file path is only supported in Node.js. |
upload({ stream }) | there is no Node stream to pass; send a File or Blob as data |
Everything else works the same in every runtime, including the SHA-256 the storage API requires on each upload, which the SDK computes with crypto.subtle.
Outside Node the SDK cannot read process.env. A browser or edge client therefore takes its credentials from the constructor, and a client built without any credential throws AuthenticationError on the spot.
Your first call
import { GigadriveClient } from '@gigadrive/sdk';
const client = new GigadriveClient({
clientId: process.env.GIGADRIVE_CLIENT_ID,
clientSecret: process.env.GIGADRIVE_CLIENT_SECRET,
});
const { items: applications, total } = await client.applications.list();
console.log(`${total} applications`);
for (const application of applications) {
console.log(application.id, application.name);
}The client id is an API key ID and the secret is the gdnet_secret_ value that key returned once, when it was created. The client exchanges the pair for an access token on the first request and caches it. Almost every list call answers with { items, total }, so destructuring items is the pattern you will write most.
Inside a deployed Function, drop the arguments entirely. new GigadriveClient() picks up the credential and the application context the platform injects, which is covered in OIDC federation.
Constructor credentials, the environment variables the client reads, and the order it reads them in.
ResourcesEvery resource family on the client, with its methods and the endpoint behind each one.
Uploading filesResumable uploads, progress and cancellation, and the low-level upload session API.
Errors and paginationThe error classes, what the client retries, and how to walk a list endpoint.
CLIThe gigadrive command, which provisions local credentials for the SDK.
The HTTP endpoints the SDK calls, for languages it does not cover.
