@bejibun/core 0.1.69 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/bases/BaseController.js +3 -2
- package/builders/StorageBuilder.d.ts +1 -0
- package/builders/StorageBuilder.js +30 -0
- package/config/disk.js +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
## [v0.1.71](https://github.com/Bejibun-Framework/bejibun-core/compare/v0.1.70...v0.1.71) - 2026-01-29
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
- Merge request payload json with other types
|
|
10
|
+
|
|
11
|
+
### 📖 Changes
|
|
12
|
+
|
|
13
|
+
### ❤️Contributors
|
|
14
|
+
- Havea Crenata ([@crenata](https://github.com/crenata))
|
|
15
|
+
|
|
16
|
+
**Full Changelog**: https://github.com/Bejibun-Framework/bejibun-core/blob/master/CHANGELOG.md
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## [v0.1.70](https://github.com/Bejibun-Framework/bejibun-core/compare/v0.1.69...v0.1.70) - 2026-01-19
|
|
21
|
+
|
|
22
|
+
### 🩹 Fixes
|
|
23
|
+
|
|
24
|
+
### 📖 Changes
|
|
25
|
+
- Added S3 storage support - [#13](https://github.com/Bejibun-Framework/bejibun-core/pull/13)
|
|
26
|
+
|
|
27
|
+
### ❤️Contributors
|
|
28
|
+
- Havea Crenata ([@crenata](https://github.com/crenata))
|
|
29
|
+
|
|
30
|
+
**Full Changelog**: https://github.com/Bejibun-Framework/bejibun-core/blob/master/CHANGELOG.md
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
6
34
|
## [v0.1.69](https://github.com/Bejibun-Framework/bejibun-core/compare/v0.1.66...v0.1.69) - 2026-01-13
|
|
7
35
|
|
|
8
36
|
### 🩹 Fixes
|
package/bases/BaseController.js
CHANGED
|
@@ -6,9 +6,10 @@ export default class BaseController {
|
|
|
6
6
|
async parse(request) {
|
|
7
7
|
const contentType = defineValue(request.headers.get("content-type"), "");
|
|
8
8
|
const formData = new FormData();
|
|
9
|
+
let data = {};
|
|
9
10
|
try {
|
|
10
11
|
if (contentType.includes("application/json"))
|
|
11
|
-
|
|
12
|
+
Object.assign(data, Bobject.serialize(await request.json()));
|
|
12
13
|
for (const [key, value] of Object.entries(request.params)) {
|
|
13
14
|
formData.append(key, value);
|
|
14
15
|
}
|
|
@@ -30,7 +31,7 @@ export default class BaseController {
|
|
|
30
31
|
catch {
|
|
31
32
|
// do nothing
|
|
32
33
|
}
|
|
33
|
-
return Bobject.parseFormData(formData);
|
|
34
|
+
return Object.assign(data, Bobject.parseFormData(formData));
|
|
34
35
|
}
|
|
35
36
|
get response() {
|
|
36
37
|
return Response;
|
|
@@ -7,6 +7,7 @@ export default class StorageBuilder {
|
|
|
7
7
|
private get config();
|
|
8
8
|
private get currentDisk();
|
|
9
9
|
private get driver();
|
|
10
|
+
private get s3();
|
|
10
11
|
build(overrideDisk: StorageDisk): StorageBuilder;
|
|
11
12
|
disk(drive: string): StorageBuilder;
|
|
12
13
|
exists(filepath: string): Promise<boolean>;
|
|
@@ -39,11 +39,30 @@ export default class StorageBuilder {
|
|
|
39
39
|
if (isEmpty(this.currentDisk?.root))
|
|
40
40
|
throw new DiskException(`Missing "root" for "local" disk configuration.`);
|
|
41
41
|
break;
|
|
42
|
+
case DiskDriverEnum.S3:
|
|
43
|
+
if (isEmpty(this.currentDisk?.endpoint))
|
|
44
|
+
throw new DiskException(`Missing "endpoint" for "s3" disk configuration.`);
|
|
45
|
+
if (isEmpty(this.currentDisk?.access_key_id))
|
|
46
|
+
throw new DiskException(`Missing "access_key_id" for "s3" disk configuration.`);
|
|
47
|
+
if (isEmpty(this.currentDisk?.secret_access_key))
|
|
48
|
+
throw new DiskException(`Missing "secret_access_key" for "s3" disk configuration.`);
|
|
49
|
+
break;
|
|
42
50
|
default:
|
|
43
51
|
break;
|
|
44
52
|
}
|
|
45
53
|
return driver;
|
|
46
54
|
}
|
|
55
|
+
get s3() {
|
|
56
|
+
if (this.driver !== DiskDriverEnum.S3)
|
|
57
|
+
throw new DiskException(`Driver is not "s3".`);
|
|
58
|
+
return new Bun.S3Client({
|
|
59
|
+
endpoint: this.currentDisk?.endpoint,
|
|
60
|
+
region: this.currentDisk?.region,
|
|
61
|
+
bucket: this.currentDisk?.bucket,
|
|
62
|
+
accessKeyId: this.currentDisk?.access_key_id,
|
|
63
|
+
secretAccessKey: this.currentDisk?.secret_access_key
|
|
64
|
+
});
|
|
65
|
+
}
|
|
47
66
|
build(overrideDisk) {
|
|
48
67
|
this.overrideDisk = overrideDisk;
|
|
49
68
|
return this;
|
|
@@ -58,6 +77,8 @@ export default class StorageBuilder {
|
|
|
58
77
|
switch (this.driver) {
|
|
59
78
|
case DiskDriverEnum.Local:
|
|
60
79
|
return await Bun.file(path.resolve(this.currentDisk.root, filepath)).exists();
|
|
80
|
+
case DiskDriverEnum.S3:
|
|
81
|
+
return await this.s3.file(filepath).exists();
|
|
61
82
|
default:
|
|
62
83
|
return false;
|
|
63
84
|
}
|
|
@@ -75,6 +96,9 @@ export default class StorageBuilder {
|
|
|
75
96
|
case DiskDriverEnum.Local:
|
|
76
97
|
data = await Bun.file(path.resolve(this.currentDisk.root, filepath)).text();
|
|
77
98
|
break;
|
|
99
|
+
case DiskDriverEnum.S3:
|
|
100
|
+
data = await this.s3.file(filepath).text();
|
|
101
|
+
break;
|
|
78
102
|
default:
|
|
79
103
|
break;
|
|
80
104
|
}
|
|
@@ -90,6 +114,9 @@ export default class StorageBuilder {
|
|
|
90
114
|
case DiskDriverEnum.Local:
|
|
91
115
|
await Bun.write(path.resolve(this.currentDisk.root, filepath), content);
|
|
92
116
|
break;
|
|
117
|
+
case DiskDriverEnum.S3:
|
|
118
|
+
await this.s3.write(filepath, content);
|
|
119
|
+
break;
|
|
93
120
|
default:
|
|
94
121
|
break;
|
|
95
122
|
}
|
|
@@ -105,6 +132,9 @@ export default class StorageBuilder {
|
|
|
105
132
|
case DiskDriverEnum.Local:
|
|
106
133
|
await Bun.file(path.resolve(this.currentDisk.root, filepath)).delete();
|
|
107
134
|
break;
|
|
135
|
+
case DiskDriverEnum.S3:
|
|
136
|
+
await this.s3.file(filepath).delete();
|
|
137
|
+
break;
|
|
108
138
|
default:
|
|
109
139
|
break;
|
|
110
140
|
}
|
package/config/disk.js
CHANGED
|
@@ -11,6 +11,15 @@ const config = {
|
|
|
11
11
|
driver: DiskDriverEnum.Local,
|
|
12
12
|
root: App.Path.storagePath("app/public"),
|
|
13
13
|
url: `${Bun.env.APP_URL}/storage/public`
|
|
14
|
+
},
|
|
15
|
+
s3: {
|
|
16
|
+
driver: DiskDriverEnum.S3,
|
|
17
|
+
endpoint: Bun.env.S3_ENDPOINT,
|
|
18
|
+
region: Bun.env.S3_REGION,
|
|
19
|
+
bucket: Bun.env.S3_BUCKET,
|
|
20
|
+
access_key_id: Bun.env.S3_ACCESS_KEY_ID,
|
|
21
|
+
secret_access_key: Bun.env.S3_SECRET_ACCESS_KEY,
|
|
22
|
+
url: ""
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
};
|