@venturekit/storage
v0.0.0-dev.20260507015944
Published
Storage layer for VentureKit
Readme
@venturekit/storage
Warning: This package is in active development and not production-ready. APIs may change without notice.
Storage layer for VentureKit — S3 configuration with CDN, lifecycle, and CORS support.
Installation
npm install @venturekit/storage@devOverview
@venturekit/storage provides:
- S3 configuration —
createS3Config(),buildS3Config()for bucket setup - Type definitions for storage buckets, lifecycle policies, CDN, and CORS
- Infrastructure intent integration — declare storage needs in
vk.config.ts
Usage
Via Infrastructure Intents (Recommended)
Declare storage buckets in your VentureKit config:
import { defineVenture } from '@venturekit/infra';
export default defineVenture({
// ...
infrastructure: {
storage: [
{ id: 'uploads', purpose: 'uploads', versioned: true },
{ id: 'assets', purpose: 'assets', cdn: true, corsOrigins: ['*'] },
{ id: 'backups', purpose: 'backups' },
],
},
});Accessing Storage in Handlers
import { handler } from '@venturekit/runtime';
import type { IntentOutputs } from '@venturekit/core';
export const main = handler(async (_body, ctx, logger) => {
const outputs = ctx.intentOutputs as IntentOutputs;
const bucketName = outputs.storage['uploads'].bucketName;
const cdnUrl = outputs.storage['assets'].cdnUrl;
// Use AWS SDK to interact with the bucket
});Direct Configuration
import { createS3Config, DEFAULT_S3_CONFIG } from '@venturekit/storage';
const s3Config = createS3Config({
bucketName: 'my-uploads',
versioned: true,
cdn: true,
});Storage Purposes
| Purpose | Description |
|---------|-------------|
| uploads | User-uploaded files |
| assets | Static assets (images, CSS, JS) |
| backups | Database and application backups |
| logs | Application and access logs |
API Reference
See the API reference for full documentation.
License
Apache-2.0 — see LICENSE for details.
