Skip to content

Commit 93be67b

Browse files
committed
Added changelog
1 parent d8ad1a4 commit 93be67b

File tree

3 files changed

+150
-3
lines changed

3 files changed

+150
-3
lines changed

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [2.0.0] - 2025-12-02
9+
10+
### ⚠️ Breaking Changes
11+
12+
- **File Path Format**: All file paths now use `minio://bucket-name/file-path` format instead of `bucket-name/file-path`
13+
- `uploadFile()` now returns `minio://bucket/file` format
14+
- Only strings starting with `minio://` are automatically transformed to presigned URLs
15+
- Removed backward compatibility with `bucket/file` format
16+
- This prevents accidental transformation of other URLs (like `otpauth://`, `http://`, etc.)
17+
18+
### Added
19+
20+
- `parseMinioUrl()` method in `MinioService` to parse `minio://` URLs
21+
- Enhanced `deleteFile()` method to accept both `minio://` URLs and separate `bucketName`/`objectName` parameters
22+
- Explicit URL transformation based on `minio://` prefix for better safety and clarity
23+
24+
### Fixed
25+
26+
- **Critical**: Fixed issue where non-minio URLs (like `otpauth://totp/...`) were incorrectly transformed to MinIO URLs
27+
- Improved URL transformation to be explicit and safe - only processes strings with `minio://` prefix
28+
- Removed inference logic that could incorrectly identify any string with `/` as a MinIO path
29+
30+
### Changed
31+
32+
- `FileUrlTransformInterceptor` now only processes strings starting with `minio://` prefix
33+
- `MinioFileInterceptor` updated to handle `minio://` format
34+
- Removed all path inference logic - transformation is now explicit and safe
35+
36+
### Migration
37+
38+
See [README.md](./README.md#migration-guide-v1x--v200) for detailed migration guide from v1.x to v2.0.0.
39+
40+
**Quick Migration Steps:**
41+
1. Update database: Migrate `bucket/file` paths to `minio://bucket/file`
42+
2. Update code: Use `minio://` prefix when constructing file paths manually
43+
3. Test: Verify all file operations work correctly
44+
45+
---
46+
47+
## [1.0.17] - Previous Version
48+
49+
### Features
50+
- File upload and management with MinIO
51+
- Automatic presigned URL generation
52+
- Decorator-based file handling
53+
- Support for TypeORM and Mongoose
54+
- Query builder result transformation
55+
56+
---
57+
58+
[2.0.0]: https://github.com/UtilKit/nestjs-minio-backend/compare/v1.0.17...v2.0.0
59+
[1.0.17]: https://github.com/UtilKit/nestjs-minio-backend/releases/tag/v1.0.17
60+

README.md

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ A powerful and flexible NestJS module for integrating MinIO object storage into
1111

1212
## Table of Contents
1313
- [Features](#features)
14+
- [Migration Guide (v1.x → v2.0.0)](#migration-guide-v1x--v200)
1415
- [Installation](#installation)
1516
- [Requirements](#requirements)
1617
- [Quick Start](#quick-start-using-decorators)
@@ -35,6 +36,91 @@ A powerful and flexible NestJS module for integrating MinIO object storage into
3536
- 🔄 RxJS integration
3637
- 🧩 Optional `@nestjs/mongoose` integration (only required if you use `@FileSchemaField`)
3738
- 🤖 Automatic presigned URL detection even for raw QueryBuilder results
39+
- 🔒 Explicit `minio://` prefix format for safe URL transformation
40+
41+
## Migration Guide (v1.x → v2.0.0)
42+
43+
### ⚠️ Breaking Changes
44+
45+
**File Path Format Change**: Starting from v2.0.0, all file paths are stored in `minio://bucket-name/file-path` format instead of `bucket-name/file-path`.
46+
47+
#### What Changed?
48+
49+
- `uploadFile()` now returns `minio://bucket/file` format
50+
- Only strings starting with `minio://` are automatically transformed to presigned URLs
51+
- This prevents accidental transformation of other URLs (like `otpauth://`, `http://`, `https://`, etc.)
52+
- Removed backward compatibility with `bucket/file` format
53+
54+
#### Why This Change?
55+
56+
The previous version had an issue where any string containing a `/` character could be incorrectly identified as a MinIO path, causing unwanted URL transformations. For example, OTP URLs like `otpauth://totp/NodeLink:user?secret=...` were being incorrectly transformed.
57+
58+
The new `minio://` prefix ensures:
59+
-**Explicit identification**: Only intentionally marked file paths are transformed
60+
-**Safety**: Other URLs remain untouched
61+
-**Clarity**: Developers can clearly see which fields are MinIO file references
62+
63+
#### Migration Steps
64+
65+
1. **Update your database**: Migrate existing file paths from `bucket/file` to `minio://bucket/file`
66+
67+
```sql
68+
-- Example SQL migration (adjust for your database)
69+
-- PostgreSQL
70+
UPDATE users SET avatar = CONCAT('minio://', avatar) WHERE avatar NOT LIKE 'minio://%' AND avatar LIKE '%/%';
71+
72+
-- MySQL
73+
UPDATE users SET avatar = CONCAT('minio://', avatar) WHERE avatar NOT LIKE 'minio://%' AND avatar LIKE '%/%';
74+
75+
-- MongoDB
76+
db.users.updateMany(
77+
{ avatar: { $exists: true, $not: /^minio:\/\// } },
78+
[{ $set: { avatar: { $concat: ["minio://", "$avatar"] } } }]
79+
);
80+
```
81+
82+
2. **Update your code**: If you manually construct file paths, use `minio://` prefix:
83+
84+
```typescript
85+
// Before (v1.x)
86+
const filePath = `${bucketName}/${fileName}`;
87+
88+
// After (v2.0.0)
89+
const filePath = `minio://${bucketName}/${fileName}`;
90+
```
91+
92+
3. **Delete operations**: The `deleteFile()` method now accepts both formats for easier migration:
93+
94+
```typescript
95+
// Both work:
96+
await minioService.deleteFile('minio://bucket/file');
97+
await minioService.deleteFile('bucket', 'file');
98+
```
99+
100+
4. **Manual file path construction**: If you're building file paths manually:
101+
102+
```typescript
103+
// Before (v1.x)
104+
const storedPath = await minioService.uploadFile(file, 'my-bucket');
105+
// Returns: "my-bucket/file-name.jpg"
106+
107+
// After (v2.0.0)
108+
const storedPath = await minioService.uploadFile(file, 'my-bucket');
109+
// Returns: "minio://my-bucket/file-name.jpg"
110+
```
111+
112+
#### Benefits
113+
114+
-**No more accidental URL transformations**: Other URLs (OTP, HTTP, etc.) are never touched
115+
-**Explicit file path identification**: Clear distinction between MinIO paths and other URLs
116+
-**Works seamlessly with query builders**: Automatic transformation still works for nested objects
117+
-**Better type safety**: Clearer intent in your codebase
118+
119+
#### Need Help?
120+
121+
If you encounter any issues during migration, please:
122+
- Open an issue on [GitHub](https://github.com/UtilKit/nestjs-minio-backend/issues)
123+
- Check the [CHANGELOG.md](./CHANGELOG.md) for detailed changes
38124

39125
## Installation
40126

@@ -193,7 +279,7 @@ export class User {
193279

194280
@FileColumn({ bucketName: 'profiles' })
195281
@Column({ nullable: true })
196-
avatar?: string; // Stores the MinIO object path (bucket/objectName)
282+
avatar?: string; // Stores the MinIO object path (minio://bucket/objectName)
197283
}
198284
```
199285

@@ -208,7 +294,7 @@ export class User {
208294
bucketName: 'profiles',
209295
required: true
210296
})
211-
avatar: string; // Automatically stores the MinIO object URL
297+
avatar: string; // Automatically stores the MinIO object path (minio://bucket/objectName)
212298
}
213299
```
214300

@@ -217,7 +303,7 @@ These decorators provide:
217303
- 📝 Automatic Swagger documentation
218304
- ✅ Built-in validation
219305
- 🔄 Seamless MongoDB integration
220-
- 🤖 Automatic presigned URL generation even for raw QueryBuilder objects (bucket names are auto-detected from your MinIO config)
306+
- 🤖 Automatic presigned URL generation even for raw QueryBuilder objects (only for strings starting with `minio://`)
221307
- 🎯 Type safety with TypeScript
222308
- 🧩 Optional Mongoose dependency (install `@nestjs/mongoose` only if you plan to use `@FileSchemaField`)
223309

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"files": [
2929
"dist",
3030
"README.md",
31+
"CHANGELOG.md",
3132
"LICENSE"
3233
],
3334
"keywords": [

0 commit comments

Comments
 (0)