@bejibun/core 0.1.53 → 0.1.54

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.54](https://github.com/crenata/bejibun-core/compare/v0.1.53...v0.1.54) - 2025-11-28
7
+
8
+ ### 🩹 Fixes
9
+ - Fix x402 middleware for optional
10
+
11
+ ### 📖 Changes
12
+
13
+ ### ❤️Contributors
14
+ - Ghulje ([@ghulje](https://github.com/ghulje))
15
+
16
+ **Full Changelog**: https://github.com/crenata/bejibun-core/blob/master/CHANGELOG.md
17
+
18
+ ---
19
+
6
20
  ## [v0.1.53](https://github.com/crenata/bejibun-core/compare/v0.1.52...v0.1.53) - 2025-11-24
7
21
 
8
22
  ### 🩹 Fixes
@@ -4,7 +4,6 @@ import HttpMethodEnum from "@bejibun/utils/enums/HttpMethodEnum";
4
4
  import Enum from "@bejibun/utils/facades/Enum";
5
5
  import path from "path";
6
6
  import RouterInvalidException from "../exceptions/RouterInvalidException";
7
- import X402Middleware from "../middlewares/X402Middleware";
8
7
  export default class RouterBuilder {
9
8
  basePath = "";
10
9
  middlewares = [];
@@ -24,6 +23,7 @@ export default class RouterBuilder {
24
23
  x402(config, facilitatorConfig, paywallConfig) {
25
24
  if (!isModuleExists("@bejibun/x402"))
26
25
  throw new RouterInvalidException("@bejibun/x402 is not installed.");
26
+ const X402Middleware = require("../middlewares/X402Middleware").default;
27
27
  this.middlewares.push(new X402Middleware(config, facilitatorConfig, paywallConfig));
28
28
  return this;
29
29
  }
@@ -0,0 +1,10 @@
1
+ export default class StorageBuilder {
2
+ protected file: any;
3
+ protected directory?: string;
4
+ protected name?: string;
5
+ constructor();
6
+ setFile(file: any): StorageBuilder;
7
+ setDirectory(directory: string): StorageBuilder;
8
+ setName(name: string): StorageBuilder;
9
+ save(): Promise<any>;
10
+ }
@@ -0,0 +1,29 @@
1
+ import App from "@bejibun/app";
2
+ import { isEmpty } from "@bejibun/utils";
3
+ import Luxon from "@bejibun/utils/facades/Luxon";
4
+ import path from "path";
5
+ export default class StorageBuilder {
6
+ file;
7
+ directory;
8
+ name;
9
+ constructor() {
10
+ this.name = "";
11
+ }
12
+ setFile(file) {
13
+ this.file = file;
14
+ return this;
15
+ }
16
+ setDirectory(directory) {
17
+ this.directory = directory;
18
+ return this;
19
+ }
20
+ setName(name) {
21
+ this.name = name;
22
+ return this;
23
+ }
24
+ async save() {
25
+ if (isEmpty(this.name))
26
+ this.name = `${Luxon.DateTime.now().toUnixInteger()}-${Math.random().toString(36).substring(2, 2 + 16)}`;
27
+ await Bun.write(App.Path.storagePath(`app/public/${this.directory}/${this.name}${path.extname(this.file?.name)}`), this.file);
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ export default class Storage {
2
+ static save(file: any, directory?: string, name?: string): Promise<any>;
3
+ }
@@ -0,0 +1,12 @@
1
+ import { isNotEmpty } from "@bejibun/utils";
2
+ import StorageBuilder from "../builders/StorageBuilder";
3
+ export default class Storage {
4
+ static async save(file, directory, name) {
5
+ const builder = new StorageBuilder().setFile(file);
6
+ if (isNotEmpty(directory))
7
+ builder.setDirectory(directory);
8
+ if (isNotEmpty(name))
9
+ builder.setName(name);
10
+ return await builder.save();
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/core",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",