@davaux/storage
v0.9.0
Published
Zero-dependency S3-compatible object storage client for Davaux
Readme
@davaux/storage
Zero-dependency S3-compatible object storage client for Davaux.
Uses hand-rolled AWS Signature V4 signing over fetch — no SDK dependency.
Works against any S3-compatible provider (Linode Object Storage, Cloudflare
R2, MinIO, AWS S3).
Installation
npm install @davaux/storageUsage
import { createS3Client } from '@davaux/storage'
const s3 = createS3Client({
endpoint: process.env.S3_ENDPOINT!, // hostname only, e.g. 'us-southeast-1.linodeobjects.com'
region: process.env.S3_REGION!,
bucket: process.env.S3_BUCKET!,
accessKeyId: process.env.S3_ACCESS_KEY_ID!,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY!,
})
// Buckets are private by default on most providers — pass `acl: 'public-read'`
// for objects that should be directly viewable by browsers (avatars, banners, etc.)
const { url } = await s3.putObject('avatars/123/abc.png', buffer, 'image/png', {
acl: 'public-read',
})
await s3.deleteObject('avatars/123/abc.png')
s3.getPublicUrl('avatars/123/abc.png')Options
| Option | Type | Description |
|---|---|---|
| endpoint | string | Hostname only, no protocol |
| region | string | Signing region |
| bucket | string | Bucket name |
| accessKeyId | string | Access key |
| secretAccessKey | string | Secret key |
| publicUrl | string | Optional CDN/custom domain base URL used instead of the virtual-hosted-style bucket URL |
