Skip to content

Commit

Permalink
refactor: bun s3
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Jan 23, 2025
1 parent 58eb975 commit 44ba8f6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.50",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "bun --watch src/index.ts",
"dev": "bun --hot --target=bun src/index.ts",
"build": "bun build --compile src/index.ts --target=bun --sourcemap --outfile undb",
"build:docker": "bun build --compile src/index.ts --target=bun --packages=external --sourcemap --outfile undb"
},
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/src/modules/file/storage/s3-object.storaget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class S3ObjectStorage implements IObjectStorage {
region: env.UNDB_S3_STORAGE_REGION!,
})

async presign(fileName: string, _path: string, mimeType: string): Promise<IPresign> {
presign(fileName: string, _path: string, mimeType: string): IPresign {
const id = v7()
const token = nanoid(16)
const ext = path.extname(fileName)
Expand All @@ -31,7 +31,7 @@ export class S3ObjectStorage implements IObjectStorage {
}
}

async getPreviewUrl(fileName: string): Promise<string> {
getPreviewUrl(fileName: string): string {
return this.s3Client.presign(fileName, { bucket: env.UNDB_STORAGE_PRIVATE_BUCKET, expiresIn: 24 * 60 * 60 })
}

Expand Down
51 changes: 0 additions & 51 deletions docker-compose.dev.yaml

This file was deleted.

51 changes: 51 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
services:
# undb:
# build:
# context: .
# dockerfile: Dockerfile.dev
# container_name: undb
# volumes:
# - .:/app
# - /app/node_modules
# ports:
# - 3721:3721
# environment:
# - LOG_LEVEL=debug
# - UNDB_BASE_URL=http://localhost:3721
# - UNDB_DB_PROVIDER=turso
# - UNDB_DB_TURSO_URL=http://db:8080
# - UNDB_STORAGE_PROVIDER=minio
# - UNDB_MINIO_STORAGE_ENDPOINT=http://minio:9000
# - UNDB_VERIFY_EMAIL=true
# - UNDB_MAIL_HOST=maildev
# - UNDB_MAIL_PORT=1025
# - UNDB_DISABLE_REGISTRATION=true
# - UNDB_ADMIN_EMAIL=admin@undb.io
# - UNDB_ADMIN_PASSWORD=admin
# depends_on:
# - db
# - minio
# - maildev

# db:
# image: ghcr.io/tursodatabase/libsql-server:latest
# environment:
# - SQLD_NODE=primary
# volumes:
# - ./apps/backend/.undb:/var/lib/sqld

minio:
image: quay.io/minio/minio
container_name: minio
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
volumes:
- ./minio/data:/data
command: server /data --console-address ":9001"

maildev:
image: maildev/maildev
4 changes: 2 additions & 2 deletions packages/table/src/modules/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export interface IPresign {
}

export interface IObjectStorage {
presign(fileName: string, path: string, mimeType: string): Promise<IPresign>
getPreviewUrl(fileName: string): Promise<string>
presign(fileName: string, path: string, mimeType: string): Promise<IPresign> | IPresign
getPreviewUrl(fileName: string): Promise<string> | string
put(buffer: Buffer, path: string, originalname: string, mimeType: string): Promise<IPutObject>
get(id: string): Promise<Buffer>
}

0 comments on commit 44ba8f6

Please sign in to comment.