fiberx-backend-toolkit 0.0.19 → 0.0.21

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.
@@ -76,12 +76,3 @@ class CreateSchemaScript {
76
76
  }
77
77
  }
78
78
  exports.default = CreateSchemaScript;
79
- // CLI entry point
80
- try {
81
- new CreateSchemaScript(process.argv[2]).run();
82
- process.exit(0);
83
- }
84
- catch (error) {
85
- console.error(error?.message || "");
86
- process.exit(1);
87
- }
@@ -167,11 +167,3 @@ class MakeMigrationsScript {
167
167
  }
168
168
  }
169
169
  exports.default = MakeMigrationsScript;
170
- // CLI entry point
171
- try {
172
- new MakeMigrationsScript().run();
173
- }
174
- catch (error) {
175
- console.error(error?.message || "");
176
- process.exit(1);
177
- }
@@ -118,27 +118,3 @@ class MigrationRunnerScript {
118
118
  }
119
119
  }
120
120
  exports.default = MigrationRunnerScript;
121
- // -----------------------
122
- // CLI ENTRY POINT
123
- // -----------------------
124
- (async () => {
125
- try {
126
- const args = process.argv.slice(2);
127
- // Parse CLI args
128
- const operation_arg = args.find(arg => arg.startsWith("--operation=")) || "--operation=up";
129
- const schema_arg = args.find(arg => arg.startsWith("--schema_name="));
130
- const file_arg = args.find(arg => arg.startsWith("--file_name="));
131
- const operation = operation_arg.split("=")[1];
132
- const schema_name = schema_arg ? schema_arg.split("=")[1] : undefined;
133
- const migration_file = file_arg ? file_arg.split("=")[1] : undefined;
134
- if (!["up", "down"].includes(operation)) {
135
- throw new Error(`Invalid operation: ${operation}. Must be "up" or "down".`);
136
- }
137
- await new MigrationRunnerScript().run(operation, schema_name, migration_file);
138
- process.exit(0);
139
- }
140
- catch (error) {
141
- console.error("❌", error?.message || error);
142
- process.exit(1);
143
- }
144
- })();
@@ -106,26 +106,3 @@ class SeederRunnerScript {
106
106
  }
107
107
  }
108
108
  exports.default = SeederRunnerScript;
109
- // -----------------------
110
- // CLI ENTRY POINT
111
- // -----------------------
112
- (async () => {
113
- try {
114
- const args = process.argv.slice(2);
115
- const operation_arg = args.find(arg => arg.startsWith("--operation=")) || "--operation=up";
116
- const seeder_arg = args.find(arg => arg.startsWith("--seeder="));
117
- const file_arg = args.find(arg => arg.startsWith("--file_name="));
118
- const operation = operation_arg.split("=")[1];
119
- const seeder_name = seeder_arg ? seeder_arg.split("=")[1] : undefined;
120
- const seeder_file = file_arg ? file_arg.split("=")[1] : undefined;
121
- if (!["up", "down"].includes(operation)) {
122
- throw new Error(`Invalid operation: ${operation}. Must be "up" or "down".`);
123
- }
124
- await new SeederRunnerScript().run(operation, seeder_name, seeder_file);
125
- process.exit(0);
126
- }
127
- catch (error) {
128
- console.error(`❌ ${error?.message}`, { error });
129
- process.exit(1);
130
- }
131
- })();
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
13
  };
@@ -65,6 +68,9 @@ class CookieManagerMiddleWare {
65
68
  }
66
69
  }
67
70
  __decorate([
68
- main_1.SafeExecuteUtil.safeExecuteThrow("cookie_manager_middle_ware")
71
+ main_1.SafeExecuteUtil.safeExecuteThrow("cookie_manager_middle_ware"),
72
+ __metadata("design:type", Function),
73
+ __metadata("design:paramtypes", [Object, Object, Function]),
74
+ __metadata("design:returntype", Promise)
69
75
  ], CookieManagerMiddleWare.prototype, "middleWare", null);
70
76
  exports.default = CookieManagerMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const constants_1 = require("../config/constants");
10
13
  const main_1 = require("../utils/main");
@@ -108,15 +111,27 @@ class CorsMiddleWare {
108
111
  ;
109
112
  }
110
113
  __decorate([
111
- main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", [])
114
+ main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", []),
115
+ __metadata("design:type", Function),
116
+ __metadata("design:paramtypes", []),
117
+ __metadata("design:returntype", Promise)
112
118
  ], CorsMiddleWare.prototype, "resolveAllowedOrigins", null);
113
119
  __decorate([
114
- main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", false)
120
+ main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", false),
121
+ __metadata("design:type", Function),
122
+ __metadata("design:paramtypes", [String]),
123
+ __metadata("design:returntype", Promise)
115
124
  ], CorsMiddleWare.prototype, "isValidOrigin", null);
116
125
  __decorate([
117
- main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", "unknown")
126
+ main_1.SafeExecuteUtil.safeExecuteReturn("cors_middle_ware", "unknown"),
127
+ __metadata("design:type", Function),
128
+ __metadata("design:paramtypes", [Object]),
129
+ __metadata("design:returntype", Promise)
118
130
  ], CorsMiddleWare.prototype, "getRequestOrigin", null);
119
131
  __decorate([
120
- main_1.SafeExecuteUtil.safeExecuteThrow("cors_middle_ware")
132
+ main_1.SafeExecuteUtil.safeExecuteThrow("cors_middle_ware"),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [Object, Object, Function]),
135
+ __metadata("design:returntype", Promise)
121
136
  ], CorsMiddleWare.prototype, "middleWare", null);
122
137
  exports.default = CorsMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const main_1 = require("../utils/main");
10
13
  class HTTPSEnforcementMiddleWare {
@@ -38,6 +41,9 @@ class HTTPSEnforcementMiddleWare {
38
41
  }
39
42
  }
40
43
  __decorate([
41
- main_1.SafeExecuteUtil.safeExecuteThrow("https_enforcement_middle_ware")
44
+ main_1.SafeExecuteUtil.safeExecuteThrow("https_enforcement_middle_ware"),
45
+ __metadata("design:type", Function),
46
+ __metadata("design:paramtypes", [Object, Object, Function]),
47
+ __metadata("design:returntype", Promise)
42
48
  ], HTTPSEnforcementMiddleWare.prototype, "middleWare", null);
43
49
  exports.default = HTTPSEnforcementMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const main_1 = require("../utils/main");
10
13
  const constants_1 = require("../config/constants");
@@ -72,6 +75,9 @@ class RateLimiterMiddleWare {
72
75
  ;
73
76
  }
74
77
  __decorate([
75
- main_1.SafeExecuteUtil.safeExecuteThrow("rate_limiter_middle_ware")
78
+ main_1.SafeExecuteUtil.safeExecuteThrow("rate_limiter_middle_ware"),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [Object, Object, Function]),
81
+ __metadata("design:returntype", Promise)
76
82
  ], RateLimiterMiddleWare.prototype, "middleWare", null);
77
83
  exports.default = RateLimiterMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const main_1 = require("../utils/main");
10
13
  class RequestLoggerMiddleWare {
@@ -32,6 +35,9 @@ class RequestLoggerMiddleWare {
32
35
  }
33
36
  }
34
37
  __decorate([
35
- main_1.SafeExecuteUtil.safeExecuteThrow("request_logger_middle_ware")
38
+ main_1.SafeExecuteUtil.safeExecuteThrow("request_logger_middle_ware"),
39
+ __metadata("design:type", Function),
40
+ __metadata("design:paramtypes", [Object, Object, Function]),
41
+ __metadata("design:returntype", Promise)
36
42
  ], RequestLoggerMiddleWare.prototype, "middleWare", null);
37
43
  exports.default = RequestLoggerMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const main_1 = require("../utils/main");
10
13
  class ResponseFormatterMiddleWare {
@@ -66,12 +69,21 @@ class ResponseFormatterMiddleWare {
66
69
  }
67
70
  }
68
71
  __decorate([
69
- main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware")
72
+ main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware"),
73
+ __metadata("design:type", Function),
74
+ __metadata("design:paramtypes", [Object, Object, Function]),
75
+ __metadata("design:returntype", Promise)
70
76
  ], ResponseFormatterMiddleWare.prototype, "handle404ErrorMiddleWare", null);
71
77
  __decorate([
72
- main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware")
78
+ main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware"),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", [Object, Object, Object, Function]),
81
+ __metadata("design:returntype", Promise)
73
82
  ], ResponseFormatterMiddleWare.prototype, "handleGeneralErrorMiddleWare", null);
74
83
  __decorate([
75
- main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware")
84
+ main_1.SafeExecuteUtil.safeExecuteThrow("response_formatter_middle_ware"),
85
+ __metadata("design:type", Function),
86
+ __metadata("design:paramtypes", [Object, Object, Function]),
87
+ __metadata("design:returntype", Promise)
76
88
  ], ResponseFormatterMiddleWare.prototype, "middleWare", null);
77
89
  exports.default = ResponseFormatterMiddleWare;
@@ -5,6 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  const main_1 = require("../utils/main");
10
13
  class SecureHeadersMiddleWare {
@@ -94,6 +97,9 @@ class SecureHeadersMiddleWare {
94
97
  }
95
98
  }
96
99
  __decorate([
97
- main_1.SafeExecuteUtil.safeExecuteThrow("secure_headers_middle_ware")
100
+ main_1.SafeExecuteUtil.safeExecuteThrow("secure_headers_middle_ware"),
101
+ __metadata("design:type", Function),
102
+ __metadata("design:paramtypes", [Object, Object, Function]),
103
+ __metadata("design:returntype", Promise)
98
104
  ], SecureHeadersMiddleWare.prototype, "middleWare", null);
99
105
  exports.default = SecureHeadersMiddleWare;
@@ -25,6 +25,11 @@ export interface EnvConfigInterface {
25
25
  APP_ID?: string;
26
26
  [key: string]: any;
27
27
  }
28
+ export interface EnvVarConfigOptions {
29
+ development_file_name?: string;
30
+ staging_file_name?: string;
31
+ production_file_name?: string;
32
+ }
28
33
  export interface ServerErrorInterface extends Error {
29
34
  syscall?: string;
30
35
  code?: string;
@@ -1,4 +1,4 @@
1
- import { EnvConfigInterface } from "../types/util_type";
1
+ import { EnvConfigInterface, EnvVarConfigOptions } from "../types/util_type";
2
2
  declare class EnvManagerUtil {
3
3
  readonly name = "env_manager_util";
4
4
  env_file_name: string;
@@ -8,7 +8,7 @@ declare class EnvManagerUtil {
8
8
  env_data: EnvConfigInterface;
9
9
  private constructor();
10
10
  private getEnvFileName;
11
- static getInstance(): EnvManagerUtil;
11
+ static getInstance(env_var_options?: EnvVarConfigOptions): EnvManagerUtil;
12
12
  private readENVData;
13
13
  getEnvVar<T = any>(key: string, default_value?: T): T | undefined;
14
14
  fetchRemoteEnv(url: string): Promise<void>;
@@ -17,31 +17,31 @@ class EnvManagerUtil {
17
17
  logger;
18
18
  env_data;
19
19
  // 🔒 Private constructor
20
- constructor() {
21
- this.env_file_name = this.getEnvFileName();
20
+ constructor(env_var_options) {
21
+ this.env_file_name = this.getEnvFileName(env_var_options);
22
22
  this.yaml_env_file_path = path_1.default.join(constants_1.ENV_VAR_DIR, this.env_file_name);
23
23
  this.logger = new logger_util_1.default(this.name);
24
24
  this.env_data = this.readENVData();
25
25
  }
26
26
  // Method to get env file name
27
- getEnvFileName() {
27
+ getEnvFileName(env_var_options) {
28
28
  if (process?.env?.MODE === "development") {
29
- return "env.yaml";
29
+ return env_var_options?.development_file_name ?? "development_env.yaml";
30
30
  }
31
31
  else if (process?.env?.MODE === "staging") {
32
- return "staging_env.yaml";
32
+ return env_var_options?.staging_file_name ?? "staging_env.yaml";
33
33
  }
34
34
  else if (process?.env?.MODE === "production") {
35
- return "production_env.yaml";
35
+ return env_var_options?.production_file_name ?? "production_env.yaml";
36
36
  }
37
37
  else {
38
38
  return "env.yaml";
39
39
  }
40
40
  }
41
41
  // ✅ Global access point
42
- static getInstance() {
42
+ static getInstance(env_var_options) {
43
43
  if (!EnvManagerUtil.instance) {
44
- EnvManagerUtil.instance = new EnvManagerUtil();
44
+ EnvManagerUtil.instance = new EnvManagerUtil(env_var_options);
45
45
  }
46
46
  return EnvManagerUtil.instance;
47
47
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "fiberx-backend-toolkit",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
5
- "type": "module",
5
+ "type": "commonjs",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "scripts": {