@bejibun/core 0.1.69 → 0.1.70

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 CHANGED
@@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.70](https://github.com/Bejibun-Framework/bejibun-core/compare/v0.1.69...v0.1.70) - 2026-01-19
7
+
8
+ ### 🩹 Fixes
9
+
10
+ ### 📖 Changes
11
+ - Added S3 storage support - [#13](https://github.com/Bejibun-Framework/bejibun-core/pull/13)
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
+
6
20
  ## [v0.1.69](https://github.com/Bejibun-Framework/bejibun-core/compare/v0.1.66...v0.1.69) - 2026-01-13
7
21
 
8
22
  ### 🩹 Fixes
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/core",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",