@storyshelf/storage-gcs
@storyshelf/storage-gcs stores StoryShelf blobs in a Google Cloud Storage (GCS) bucket — captured screenshots, diff overlays, and uploaded Storybook archives.
Install
Section titled “Install”npm i @storyshelf/storage-gcspnpm add @storyshelf/storage-gcsyarn add @storyshelf/storage-gcs- npm package — install tarballs and version history.
- JSR package — TypeScript-first registry page.
- Public API reference — generated docs for every export; start here to learn the API. (The same reference is on JSR.)
- Source on GitHub — package directory on
main.
Configure
Section titled “Configure”import { createGcsStorage } from "@storyshelf/storage-gcs";import { createShelfApp } from "@storyshelf/app";
const storage = createGcsStorage({ bucket: "my-shelf", prefix: "storyshelf", // optional projectId: "my-gcp-project", // optional, defaults to ADC});
const app = createShelfApp({ database, storage });For local emulators or custom endpoints:
const storage = createGcsStorage({ bucket: "my-shelf", apiEndpoint: "http://localhost:9090", projectId: "test-project",});Inject a pre-configured client (tests / IAM-rotation):
import { Storage } from "@google-cloud/storage";
const client = new Storage({ projectId: "my-project" });const storage = createGcsStorage({ bucket: "my-shelf", client });GcsStorageOptions
Section titled “GcsStorageOptions”interface GcsStorageOptions { bucket: string; // required GCS bucket name prefix?: string; // optional key prefix, defaults to "" client?: Storage; // optional pre-configured @google-cloud/storage client projectId?: string; // optional GCP project id keyFilename?: string; // optional path to service-account JSON credentials?: object; // optional service-account credentials object apiEndpoint?: string; // optional custom endpoint (emulator)}Options at a glance:
| Option | Required | Notes |
|---|---|---|
bucket | yes | GCS bucket name |
prefix | no | Key prefix for every object |
client | no | Pre-built Storage client (tests, custom endpoint) |
projectId | no | GCP project ID (defaults to ADC) |
keyFilename | no | Path to service-account JSON |
credentials | no | Inline service-account object |
apiEndpoint | no | Custom endpoint (emulator, e.g. http://localhost:9090) |
Auth otherwise uses Application Default Credentials.
createGcsStorage(options: GcsStorageOptions): StorageAdapter
Section titled “createGcsStorage(options: GcsStorageOptions): StorageAdapter”Creates a StorageAdapter backed by the configured GCS bucket. The returned adapter implements every method of the StorageAdapter interface (read, write, delete, exists, list(prefix), readStream, writeStream).
gcsKey(prefix: string, path: string): string
Section titled “gcsKey(prefix: string, path: string): string”Helper that joins a storage prefix with a relative path into an object key.
When to use it
Section titled “When to use it”Use GCS for GCP deploys — Cloud Run, GKE, or Cloud Functions — especially paired with db-postgres. It is a drop-in replacement for local storage, S3, and Azure Blob.