Update README.md to provide a comprehensive overview of The Order monorepo, including repository structure, quickstart guide, development workflow, and contribution guidelines.
This commit is contained in:
22
packages/storage/README.md
Normal file
22
packages/storage/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# @the-order/storage
|
||||
|
||||
Storage abstraction for S3/GCS with WORM mode support.
|
||||
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import { StorageClient, WORMStorage } from '@the-order/storage';
|
||||
|
||||
const storage = new StorageClient(config);
|
||||
const wormStorage = new WORMStorage(config);
|
||||
|
||||
await storage.upload({ key: 'file.txt', content: 'Hello' });
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- S3 and GCS support
|
||||
- WORM (Write Once Read Many) mode
|
||||
- Presigned URL generation
|
||||
- Object lifecycle management
|
||||
|
||||
22
packages/storage/package.json
Normal file
22
packages/storage/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@the-order/storage",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Storage abstraction for S3/GCS with WORM mode support",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"lint": "eslint src --ext .ts",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.490.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.10.6",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
7
packages/storage/src/index.ts
Normal file
7
packages/storage/src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* The Order Storage Package
|
||||
*/
|
||||
|
||||
export * from './storage';
|
||||
export * from './worm';
|
||||
|
||||
43
packages/storage/src/storage.ts
Normal file
43
packages/storage/src/storage.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Storage abstraction for S3/GCS
|
||||
*/
|
||||
|
||||
export interface StorageConfig {
|
||||
provider: 's3' | 'gcs';
|
||||
bucket: string;
|
||||
region?: string;
|
||||
accessKeyId?: string;
|
||||
secretAccessKey?: string;
|
||||
}
|
||||
|
||||
export interface StorageObject {
|
||||
key: string;
|
||||
content: Buffer | string;
|
||||
contentType?: string;
|
||||
metadata?: Record<string, string>;
|
||||
}
|
||||
|
||||
export class StorageClient {
|
||||
constructor(private config: StorageConfig) {}
|
||||
|
||||
async upload(object: StorageObject): Promise<string> {
|
||||
// Implementation for file upload
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
async download(key: string): Promise<Buffer> {
|
||||
// Implementation for file download
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
async delete(key: string): Promise<void> {
|
||||
// Implementation for file deletion
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
async getPresignedUrl(key: string, expiresIn: number): Promise<string> {
|
||||
// Implementation for presigned URL generation
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
26
packages/storage/src/worm.ts
Normal file
26
packages/storage/src/worm.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* WORM (Write Once Read Many) mode storage
|
||||
*/
|
||||
|
||||
import { StorageClient, StorageObject } from './storage';
|
||||
|
||||
export class WORMStorage extends StorageClient {
|
||||
async upload(object: StorageObject): Promise<string> {
|
||||
// WORM mode: prevent overwrites
|
||||
const exists = await this.objectExists(object.key);
|
||||
if (exists) {
|
||||
throw new Error(`Object ${object.key} already exists in WORM storage`);
|
||||
}
|
||||
return super.upload(object);
|
||||
}
|
||||
|
||||
async delete(key: string): Promise<void> {
|
||||
throw new Error('Deletion not allowed in WORM mode');
|
||||
}
|
||||
|
||||
private async objectExists(key: string): Promise<boolean> {
|
||||
// Implementation to check if object exists
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
10
packages/storage/tsconfig.json
Normal file
10
packages/storage/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user