jcc-express-mvc 1.5.5 → 1.5.7

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.
Files changed (36) hide show
  1. package/index.d.ts +1 -1
  2. package/index.d.ts.map +1 -1
  3. package/lib/Application/Application.js +1 -1
  4. package/lib/Application/ApplicationBuilder.d.ts +2 -2
  5. package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
  6. package/lib/Application/ApplicationBuilder.js +2 -2
  7. package/lib/Auth/index.d.ts +1 -1
  8. package/lib/Auth/index.d.ts.map +1 -1
  9. package/lib/Auth/index.js +3 -6
  10. package/lib/Error/AppErrorHandler.d.ts.map +1 -1
  11. package/lib/Error/AppErrorHandler.js +5 -6
  12. package/lib/Error/DisplayErrorCode.d.ts +3 -2
  13. package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
  14. package/lib/Error/DisplayErrorCode.js +6 -8
  15. package/lib/Error/ErrorHightLight.d.ts +1 -1
  16. package/lib/Error/ErrorHightLight.d.ts.map +1 -1
  17. package/lib/Error/ErrorHightLight.js +22 -7
  18. package/lib/Error/ErrorStyles.d.ts +7 -0
  19. package/lib/Error/ErrorStyles.d.ts.map +1 -0
  20. package/lib/Error/ErrorStyles.js +257 -0
  21. package/lib/Middleware/index.d.ts.map +1 -1
  22. package/lib/Middleware/index.js +0 -2
  23. package/lib/Providers/RouteServiceProvider.d.ts +1 -1
  24. package/lib/Providers/RouteServiceProvider.d.ts.map +1 -1
  25. package/lib/Providers/RouteServiceProvider.js +1 -1
  26. package/lib/Response/index.js +1 -1
  27. package/lib/Server/index.d.ts +1 -0
  28. package/lib/Server/index.d.ts.map +1 -1
  29. package/lib/Validation/index.d.ts +3 -4
  30. package/lib/Validation/index.d.ts.map +1 -1
  31. package/lib/Validation/index.js +3 -4
  32. package/lib/Validation/rules.d.ts.map +1 -1
  33. package/lib/Validation/rules.js +0 -73
  34. package/lib/Validation/validate.d.ts.map +1 -1
  35. package/lib/Validation/validate.js +2 -1
  36. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { AppRequest as Request, AppResponse as Response, AppNext as Next, } from "./lib/Interface";
2
1
  export { Authentication as Auth } from "./lib/Auth";
3
2
  export { config } from "./lib/Config/Config";
3
+ export type { AppRequest as Request, AppResponse as Response, AppNext as Next, } from "./lib/Interface";
4
4
  export { bcrypt, verifyHash, jwtSign, jwtVerify, saveImage, asyncHandler, cloudinaryUpload, } from "./lib/util";
5
5
  export declare const guest: (req: import("./lib/Interface").AppRequest, res: import("./lib/Interface").AppResponse, next: import("./lib/Interface").AppNext) => any;
6
6
  export declare const apiAuth: (request: import("./lib/Interface").AppRequest, response: import("./lib/Interface").AppResponse, next: import("./lib/Interface").AppNext) => Promise<any>;
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../Framework/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,UAAU,IAAI,OAAO,EACrB,WAAW,IAAI,QAAQ,EACvB,OAAO,IAAI,IAAI,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,KAAK,yIAAuB,CAAC;AAC1C,eAAO,MAAM,OAAO,2JAAyB,CAAC;AAC9C,eAAO,MAAM,IAAI,kJAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../Framework/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EACV,UAAU,IAAI,OAAO,EACrB,WAAW,IAAI,QAAQ,EACvB,OAAO,IAAI,IAAI,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,KAAK,yIAAuB,CAAC;AAC1C,eAAO,MAAM,OAAO,2JAAyB,CAAC;AAC9C,eAAO,MAAM,IAAI,kJAAsB,CAAC"}
@@ -58,7 +58,7 @@ class Application extends ExpressApplication_1.ExpressApplication {
58
58
  const routeServiceProvider = this.resolve("RouteServiceProvider");
59
59
  //
60
60
  RouteBuilder_1.RouteBuilder.setServiceContainer(this);
61
- routeServiceProvider.loadRoutes(this.configRoutes);
61
+ await routeServiceProvider.loadRoutes(this.configRoutes);
62
62
  const server = new Server_1.Server(this);
63
63
  server.server(Number(Config_1.config.get("PORT", "5500")));
64
64
  }
@@ -4,13 +4,13 @@ import { RouteConfig } from "../Interface";
4
4
  export declare class ApplicationBuilder {
5
5
  app: Application;
6
6
  constructor(app: Application);
7
- withKernels(Kernel: any): this;
7
+ withKernel(Kernel: any): this;
8
8
  withRouting(routeConfig: RouteConfig[]): this;
9
9
  withProviders(providers: Array<new (app: Application) => ServiceProvider>): this;
10
10
  private withEvents;
11
11
  private withBroadcasting;
12
12
  withConsole(): this;
13
- withMiddleWare(): this;
13
+ withMiddleware(): this;
14
14
  create(): Application;
15
15
  }
16
16
  //# sourceMappingURL=ApplicationBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,qBAAa,kBAAkB;IACtB,GAAG,EAAE,WAAW,CAAC;gBAEZ,GAAG,EAAE,WAAW;IAIrB,WAAW,CAAC,MAAM,EAAE,GAAG;IAKvB,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE;IAOtC,aAAa,CAClB,SAAS,EAAE,KAAK,CAAC,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAAC;IAM7D,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,gBAAgB;IAIjB,WAAW;IAKX,cAAc;IAWd,MAAM;CAGd"}
1
+ {"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK3C,qBAAa,kBAAkB;IACtB,GAAG,EAAE,WAAW,CAAC;gBAEZ,GAAG,EAAE,WAAW;IAIrB,UAAU,CAAC,MAAM,EAAE,GAAG;IAKtB,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE;IAOtC,aAAa,CAClB,SAAS,EAAE,KAAK,CAAC,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAAC;IAM7D,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,gBAAgB;IAIjB,WAAW;IAKX,cAAc;IAWd,MAAM;CAGd"}
@@ -7,7 +7,7 @@ class ApplicationBuilder {
7
7
  constructor(app) {
8
8
  this.app = app;
9
9
  }
10
- withKernels(Kernel) {
10
+ withKernel(Kernel) {
11
11
  this.app.bind("HttpKernel", Kernel);
12
12
  return this;
13
13
  }
@@ -32,7 +32,7 @@ class ApplicationBuilder {
32
32
  this.app.bind("ConsoleKernel", NodeArtisanCommand_1.ConsoleKernel);
33
33
  return this;
34
34
  }
35
- withMiddleWare() {
35
+ withMiddleware() {
36
36
  //
37
37
  const kernel = this.app.resolve("HttpKernel");
38
38
  const middleware = new Middleware_1.Middleware(this.app);
@@ -9,7 +9,7 @@ export declare class Authentication {
9
9
  static login(data?: {}): Promise<false | Error | undefined>;
10
10
  static isAdmin(req: AppRequest, res: AppResponse, next: AppNext): Promise<AppResponse | undefined>;
11
11
  static verifyEmail(req: AppRequest, res: AppResponse, next: AppNext): Promise<AppResponse | undefined>;
12
- static attempt(req: AppRequest, res: AppResponse, next: AppNext): any;
12
+ static attempt(req: AppRequest, res: AppResponse, next: AppNext, redirectTo?: string): any;
13
13
  static logout(req: AppRequest, res: AppResponse, next: AppNext): void;
14
14
  }
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhE,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,WAAW;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB;CACF;AAED,qBAAa,cAAc;WAEZ,KAAK,CAAC,IAAI,KAAK;WAcf,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;WAgCxD,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAkBzE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;WAmBjD,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAQtE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Auth/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhE,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,WAAW;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB;CACF;AAED,qBAAa,cAAc;WAEZ,KAAK,CAAC,IAAI,KAAK;WAcf,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;WAgCxD,WAAW,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAkBzE,MAAM,CAAC,OAAO,CACZ,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,OAAO,EACb,UAAU,GAAE,MAAgB;WAiBhB,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAQtE"}
package/lib/Auth/index.js CHANGED
@@ -64,15 +64,12 @@ class Authentication {
64
64
  }
65
65
  }
66
66
  // Method to handle authentication attempt
67
- static attempt(req, res, next) {
68
- const { RouteServiceProvider } = (0, util_1.getProvider)("RouteServiceProvider");
67
+ static attempt(req, res, next, redirectTo = "/home") {
69
68
  try {
70
69
  let redirectBack = req.previsiousUrl;
71
70
  // Retrieve the previous URL
72
71
  const appRedirect = req.session["appRedirect"];
73
- const redirectPath = appRedirect
74
- ? appRedirect
75
- : RouteServiceProvider?.HOME || "";
72
+ const redirectPath = appRedirect ? appRedirect : redirectTo || "";
76
73
  return passport_1.default.authenticate("local", {
77
74
  successRedirect: redirectPath,
78
75
  failureRedirect: `${redirectBack ? redirectBack : "/login"}`,
@@ -88,7 +85,7 @@ class Authentication {
88
85
  if (err) {
89
86
  next(err);
90
87
  }
91
- return res.redirect("/login");
88
+ return res.redirect(300, "/login");
92
89
  });
93
90
  }
94
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AppErrorHandler.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/AppErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAStC,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAc;gBACb,GAAG,EAAE,WAAW;IAI5B;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,kBAAkB;IAMzB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,GAAG,EAAE,GAAG;CA6BjB"}
1
+ {"version":3,"file":"AppErrorHandler.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/AppErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAStC,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAc;gBACb,GAAG,EAAE,WAAW;IAI5B;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAI5B,kBAAkB;IAMzB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,GAAG,EAAE,GAAG;CA4BjB"}
@@ -21,7 +21,7 @@ class AppErrorHandler {
21
21
  }
22
22
  errorRoutesHandler() {
23
23
  return this.app.all("/*splat", (req, res) => {
24
- return res.sendFile(__dirname + "/public/pageNotFound.html");
24
+ return res.status(404).sendFile(__dirname + "/public/pageNotFound.html");
25
25
  });
26
26
  }
27
27
  extractErrorPath(stackArray, isDatabaseError = false, index = 1) {
@@ -55,13 +55,12 @@ class AppErrorHandler {
55
55
  if (err.type === error_1.DEFAULT_ENGINE_ERROR) {
56
56
  return res.status(500).json({ errors: err.message });
57
57
  }
58
- if (err.error_action === "database") {
59
- const errArray = err.stack?.split(/\n/g) || [];
60
- const errorPath = this.extractErrorPath(errArray);
61
- return DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res, req);
62
- }
63
58
  const errArray = err.stack?.split(/\n/g) || [];
59
+ //
64
60
  const errorPath = this.extractErrorPath(errArray, true);
61
+ let erorrContent = DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res, req);
62
+ return res.status(500).send(erorrContent);
63
+ //
65
64
  return DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res, req);
66
65
  });
67
66
  }
@@ -1,4 +1,5 @@
1
1
  import { ErrorHighLighter } from "./ErrorHightLight";
2
+ import { AppRequest, AppResponse } from "../Interface";
2
3
  export declare class DisplayError extends ErrorHighLighter {
3
4
  /**
4
5
  * Displays the error in the response.
@@ -7,7 +8,7 @@ export declare class DisplayError extends ErrorHighLighter {
7
8
  * @param res The Express response object.
8
9
  * @returns The response after sending the error HTML.
9
10
  */
10
- static show(errorPath: string, message: any, res: any, req?: any): any;
11
+ static show(errorPath: string, message: any, res: AppResponse, req: AppRequest): string | AppResponse | undefined;
11
12
  /**
12
13
  * Renders the error HTML response.
13
14
  * @param res The Express response object.
@@ -16,6 +17,6 @@ export declare class DisplayError extends ErrorHighLighter {
16
17
  * @param message The error message to display.
17
18
  * @returns The HTML response.
18
19
  */
19
- static renderHtml(res: any, code: string, line: any, message: any): any;
20
+ static renderHtml(code: string, line: any, message: any): string | undefined;
20
21
  }
21
22
  //# sourceMappingURL=DisplayErrorCode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayErrorCode.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/DisplayErrorCode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBAAa,YAAa,SAAQ,gBAAgB;IAChD;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG;IAqChE;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;CAMlE"}
1
+ {"version":3,"file":"DisplayErrorCode.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/DisplayErrorCode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,qBAAa,YAAa,SAAQ,gBAAgB;IAChD;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CACT,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,UAAU;IAuCjB;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;CAGxD"}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.DisplayError = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const ErrorHightLight_1 = require("./ErrorHightLight");
9
- const path_1 = __importDefault(require("path"));
10
9
  class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
11
10
  /**
12
11
  * Displays the error in the response.
@@ -22,7 +21,7 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
22
21
  const [actualPath, startLine, endLine] = pathParts[lastIndex].split(/\:/);
23
22
  pathParts[lastIndex] = actualPath;
24
23
  //if request is an API request, return JSON response
25
- if (req.url.includes("/api")) {
24
+ if (req.headers["content-type"] == "application/json") {
26
25
  return res.status(500).json({
27
26
  stack: pathParts.join("/").trim() + ` on line ${startLine}:${endLine}`,
28
27
  error: ` ${message} `,
@@ -33,7 +32,9 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
33
32
  let formattedContent = content
34
33
  .map((line, index) => `${index + 1}. ${line}`)
35
34
  .join("\n");
36
- return this.renderHtml(res, formattedContent, startLine, `${message.trim()} <p> ${pathParts.join("/").trim()} ${startLine}:${endLine} </p>`);
35
+ return this.renderHtml(formattedContent, startLine, `${message.trim()} <p> ${pathParts
36
+ .join("/")
37
+ .trim()} ${startLine}:${endLine} </p>`);
37
38
  }
38
39
  catch (error) {
39
40
  return res
@@ -49,11 +50,8 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
49
50
  * @param message The error message to display.
50
51
  * @returns The HTML response.
51
52
  */
52
- static renderHtml(res, code, line, message) {
53
- this.compileCodeToFile(code, line, message);
54
- return res
55
- .status(500)
56
- .sendFile(path_1.default.join(__dirname, "public", "error.html"));
53
+ static renderHtml(code, line, message) {
54
+ return this.compileCodeToFile(code, line, message);
57
55
  }
58
56
  }
59
57
  exports.DisplayError = DisplayError;
@@ -13,6 +13,6 @@ export declare class ErrorHighLighter {
13
13
  * @param line The line number(s) to highlight in the code.
14
14
  * @param message The error message to be displayed.
15
15
  */
16
- static compileCodeToFile(code: string, line: string | number, message: any): void;
16
+ static compileCodeToFile(code: string, line: string | number, message: any): string | undefined;
17
17
  }
18
18
  //# sourceMappingURL=ErrorHightLight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorHightLight.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/ErrorHightLight.ts"],"names":[],"mappings":"AACA,qBAAa,gBAAgB;IAC3B;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,EAAE,MAAM;IAmCjB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;CAU3E"}
1
+ {"version":3,"file":"ErrorHightLight.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/ErrorHightLight.ts"],"names":[],"mappings":"AAGA,qBAAa,gBAAgB;IAC3B;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,EAAE,MAAM;IA8CjB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;CAW3E"}
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ErrorHighLighter = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
+ const ErrorStyles_1 = require("./ErrorStyles");
9
+ const path_1 = __importDefault(require("path"));
8
10
  class ErrorHighLighter {
9
11
  /**
10
12
  * Generates an HTML template for displaying an error.
@@ -21,11 +23,9 @@ class ErrorHighLighter {
21
23
  <head>
22
24
  <meta charset="UTF-8" />
23
25
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
24
- <link rel="stylesheet" href="/css/app-error-prism.css" />
25
- <link rel="stylesheet" href="/css/app-error-prism-line.css" />
26
- <link rel="stylesheet" href="/css/app-error.css" />
27
26
  <title>Error</title>
28
- <style>
27
+ <style>
28
+ ${ErrorStyles_1.ErrorStyles.styles()}
29
29
  </style>
30
30
  </head>
31
31
  <body class="">
@@ -40,8 +40,19 @@ class ErrorHighLighter {
40
40
  ><code class="language-javascript">${code}</code></pre>
41
41
  </div>
42
42
  </div>
43
- <script src="/js/app-error-prism.js"> </script>
44
- <script src="/js/app-error-prism-line.js"> </script>
43
+ <script>
44
+ ${fs_1.default
45
+ .readFileSync(path_1.default.join(__dirname, "public/js", "app-error-prism.js"))
46
+ .toString()}
47
+ </script>
48
+ <script>
49
+ ${fs_1.default
50
+ .readFileSync(path_1.default.join(__dirname, "public/js", "app-error-prism-line.js"))
51
+ .toString()}
52
+ </script>
53
+ <script>
54
+
55
+ </script>
45
56
  </body>
46
57
  </html>
47
58
  `;
@@ -54,7 +65,11 @@ class ErrorHighLighter {
54
65
  */
55
66
  static compileCodeToFile(code, line, message) {
56
67
  try {
57
- return fs_1.default.writeFileSync(__dirname + "/public/error.html", this.generateHtmlCode(code, line, message));
68
+ // return fs.writeFileSync(
69
+ // __dirname + "/public/error.html",
70
+ // this.generateHtmlCode(code, line, message)
71
+ // );
72
+ return this.generateHtmlCode(code, line, message);
58
73
  }
59
74
  catch (error) {
60
75
  console.log(error.message);
@@ -0,0 +1,7 @@
1
+ export declare class ErrorStyles {
2
+ private static customErrorStyle;
3
+ private static prismStyle;
4
+ private static prismLineStyle;
5
+ static styles(): string;
6
+ }
7
+ //# sourceMappingURL=ErrorStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorStyles.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/ErrorStyles.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAoE/B,OAAO,CAAC,MAAM,CAAC,UAAU;IAsGzB,OAAO,CAAC,MAAM,CAAC,cAAc;IA6E7B,MAAM,CAAC,MAAM;CAOd"}
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorStyles = void 0;
4
+ class ErrorStyles {
5
+ static customErrorStyle() {
6
+ return `
7
+ * {
8
+ margin: 0;
9
+ padding: 0;
10
+ box-sizing: border-box;
11
+ }
12
+ body {
13
+ background: #0e0f1d;
14
+ display: flex;
15
+ justify-content: center;
16
+ align-items: center;
17
+ height: 100vh;
18
+ }
19
+ .code-container {
20
+ background: #151b23;
21
+ padding: 10px 0;
22
+ min-height: 60vh;
23
+ max-height: 90vh;
24
+ }
25
+ .code-container::-webkit-scrollbar {
26
+ width: 1px;
27
+ }
28
+
29
+ .code-container::-webkit-scrollbar-track {
30
+ background: #f1f1f1; /* Track color */
31
+ }
32
+
33
+ .code-container::-webkit-scrollbar-thumb {
34
+ background-color: #888; /* Handle color */
35
+ border-radius: 10px; /* Rounded corners for handle */
36
+ }
37
+
38
+ .code-container::-webkit-scrollbar-thumb:hover {
39
+ background-color: #555; /* Color when hovered */
40
+ }
41
+
42
+ .error-message {
43
+ color: #fff; /*rgba(245, 43, 43, 0.897);*/
44
+ padding: 20px;
45
+ width: 100%;
46
+ font-size: 1.3rem;
47
+ border-bottom: 1px solid #ddd;
48
+ }
49
+
50
+ @media (min-width: 640px) {
51
+ .code-container {
52
+ min-width: 50%;
53
+ max-width: 80%;
54
+ }
55
+ }
56
+
57
+ @media (min-width: 768px) {
58
+ .code-container {
59
+ min-width: 50%;
60
+ max-width: 80%;
61
+ }
62
+ }
63
+ @media (min-width: 1024px) {
64
+ .code-container {
65
+ min-width: 50%;
66
+ max-width: 60%;
67
+ }
68
+ }
69
+
70
+ `;
71
+ }
72
+ static prismStyle() {
73
+ return `
74
+ code[class*="language-"],
75
+ pre[class*="language-"] {
76
+ color: #f8f8f2;
77
+ background: 0 0;
78
+ text-shadow: 0 1px rgba(0, 0, 0, 0.3);
79
+ font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
80
+ font-size: 1em;
81
+ text-align: left;
82
+ white-space: pre;
83
+ word-spacing: normal;
84
+ word-break: normal;
85
+ word-wrap: normal;
86
+ line-height: 1.5;
87
+ -moz-tab-size: 4;
88
+ -o-tab-size: 4;
89
+ tab-size: 4;
90
+ -webkit-hyphens: none;
91
+ -moz-hyphens: none;
92
+ -ms-hyphens: none;
93
+ hyphens: none;
94
+ }
95
+ pre[class*="language-"] {
96
+ padding: 1em;
97
+ overflow: auto;
98
+ border-radius: 0.3em;
99
+ }
100
+ :not(pre) > code[class*="language-"],
101
+ pre[class*="language-"] {
102
+ background: #10151bd0;
103
+ }
104
+ :not(pre) > code[class*="language-"] {
105
+ padding: 0.1em;
106
+ border-radius: 0.3em;
107
+ white-space: normal;
108
+ }
109
+ .token.cdata,
110
+ .token.comment,
111
+ .token.doctype,
112
+ .token.prolog {
113
+ color: #8292a2;
114
+ }
115
+ .token.punctuation {
116
+ color: #cc872d;
117
+ }
118
+ .token.namespace {
119
+ opacity: 0.7;
120
+ }
121
+ .token.constant,
122
+ .token.deleted,
123
+ .token.property,
124
+ .token.symbol,
125
+ .token.tag {
126
+ color: #0786fd;
127
+ }
128
+ .token.boolean,
129
+ .token.number {
130
+ color: #767c83;
131
+ }
132
+ .token.attr-name,
133
+ .token.builtin,
134
+ .token.char,
135
+ .token.inserted,
136
+ .token.selector,
137
+ .token.string {
138
+ color: #07db43e1;
139
+ }
140
+ .language-css .token.string,
141
+ .style .token.string,
142
+ .token.entity,
143
+ .token.operator,
144
+ .token.url,
145
+ .token.variable {
146
+ color: #f8f8f2;
147
+ }
148
+ .token.atrule,
149
+ .token.attr-value,
150
+ .token.class-name,
151
+ .token.function {
152
+ color: #cf74e6;
153
+ }
154
+ .token.keyword {
155
+ color: #e22d2d;
156
+ }
157
+ .token.important,
158
+ .token.regex {
159
+ color: #fd971f;
160
+ }
161
+ .token.bold,
162
+ .token.important {
163
+ font-weight: 700;
164
+ }
165
+ .token.italic {
166
+ font-style: italic;
167
+ }
168
+ .token.entity {
169
+ cursor: help;
170
+ }
171
+ `;
172
+ }
173
+ static prismLineStyle() {
174
+ return `
175
+ pre[data-line] {
176
+ position: relative;
177
+ }
178
+
179
+ .line-highlight {
180
+ position: absolute;
181
+ left: 0;
182
+ right: 0;
183
+ padding: inherit 0;
184
+ margin-top: 0.8rem;
185
+ /* Same as .prism’s padding-top */
186
+
187
+ background: hsla(2, 93%, 47%, 0.329);
188
+ background: linear-gradient(
189
+ to right,
190
+ hsla(2, 93%, 47%, 0.329) 70%,
191
+ hsla(2, 93%, 47%, 0.329)
192
+ );
193
+
194
+ /* border-bottom: 2px dashed rgb(221, 24, 24); */
195
+ pointer-events: none;
196
+
197
+ line-height: inherit;
198
+ white-space: pre;
199
+ }
200
+
201
+ @media print {
202
+ .line-highlight {
203
+ -webkit-print-color-adjust: exact;
204
+ color-adjust: exact;
205
+ }
206
+ }
207
+
208
+ .line-highlight:before,
209
+ .line-highlight[data-end]:after {
210
+ content: attr(data-start);
211
+ position: absolute;
212
+ top: 0.4em;
213
+ left: 0.6em;
214
+ min-width: 1em;
215
+ padding: 0 0.5em;
216
+ background-color: hsla(24, 20%, 50%, 0.4);
217
+ color: hsl(24, 20%, 95%);
218
+ font: bold 65%/1.5 sans-serif;
219
+ text-align: center;
220
+ vertical-align: 0.3em;
221
+ border-radius: 999px;
222
+ text-shadow: none;
223
+ box-shadow: 0 1px white;
224
+ }
225
+
226
+ .line-highlight[data-end]:after {
227
+ content: attr(data-end);
228
+ top: auto;
229
+ bottom: 0.4em;
230
+ }
231
+
232
+ .line-numbers .line-highlight:before,
233
+ .line-numbers .line-highlight:after {
234
+ content: none;
235
+ }
236
+
237
+ pre[id].linkable-line-numbers span.line-numbers-rows {
238
+ pointer-events: all;
239
+ }
240
+ pre[id].linkable-line-numbers span.line-numbers-rows > span:before {
241
+ cursor: pointer;
242
+ }
243
+ pre[id].linkable-line-numbers span.line-numbers-rows > span:hover:before {
244
+ background-color: rgba(128, 128, 128, 0.2);
245
+ }
246
+
247
+ `;
248
+ }
249
+ static styles() {
250
+ return `
251
+ ${this.prismStyle()}
252
+ ${this.prismLineStyle()}
253
+ ${this.customErrorStyle()}
254
+ `;
255
+ }
256
+ }
257
+ exports.ErrorStyles = ErrorStyles;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAyB,EAEvB,cAAc,EACf,MAAM,SAAS,CAAC;AAUjB,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAS;gBAEb,GAAG,EAAE,WAAW;IAM5B,eAAe;IAOf,GAAG,CAAC,gBAAgB,EAAE,cAAc,EAAE;IAgBtC,OAAO,CAAC,uBAAuB;IAMxB,kBAAkB,IAAI,cAAc;CAM5C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAyB,EAEvB,cAAc,EACf,MAAM,SAAS,CAAC;AAUjB,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAS;gBAEb,GAAG,EAAE,WAAW;IAM5B,eAAe;IAMf,GAAG,CAAC,gBAAgB,EAAE,cAAc,EAAE;IAgBtC,OAAO,CAAC,uBAAuB;IAMxB,kBAAkB,IAAI,cAAc;CAM5C"}
@@ -10,7 +10,6 @@ const Response_1 = require("../Response");
10
10
  const request_1 = require("../Request/request");
11
11
  const Templating_engine_1 = require("../Templating-engine");
12
12
  const config_1 = require("../Passport/config");
13
- const path_1 = __importDefault(require("path"));
14
13
  class Middleware {
15
14
  //
16
15
  constructor(app) {
@@ -21,7 +20,6 @@ class Middleware {
21
20
  }
22
21
  loadStaticFiles() {
23
22
  this.defaultTemplatingEngine();
24
- this.app.use(this.express.static(path_1.default.join(__dirname, "../Error/public")));
25
23
  this.app.use(this.express.static(`${this.rootPath}/public`));
26
24
  this.app.use(this.express.static(`${this.rootPath}/resources`));
27
25
  this.app.use((0, serve_favicon_1.default)(`${this.rootPath}/public/favicon.ico`));
@@ -3,7 +3,7 @@ import { RouteConfig } from "../Interface";
3
3
  import { ServiceProvider } from "./ServiceProvider";
4
4
  export declare class RouteServiceProvider extends ServiceProvider {
5
5
  constructor(app: Application);
6
- loadRoutes(routeConfig: RouteConfig[]): void;
6
+ loadRoutes(routeConfig: RouteConfig[]): Promise<void>;
7
7
  register(): void;
8
8
  boot(): void;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RouteServiceProvider.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Providers/RouteServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,GAAG,EAAE,WAAW;IAI5B,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI;IAQ5C,QAAQ,IAAI,IAAI;IAEhB,IAAI,IAAI,IAAI;CACb"}
1
+ {"version":3,"file":"RouteServiceProvider.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Providers/RouteServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,GAAG,EAAE,WAAW;IAItB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3D,QAAQ,IAAI,IAAI;IAEhB,IAAI,IAAI,IAAI;CACb"}
@@ -8,7 +8,7 @@ class RouteServiceProvider extends ServiceProvider_1.ServiceProvider {
8
8
  constructor(app) {
9
9
  super(app);
10
10
  }
11
- loadRoutes(routeConfig) {
11
+ async loadRoutes(routeConfig) {
12
12
  for (const route of routeConfig) {
13
13
  Route_1.Route.prefix(route.prefix).group((Route) => {
14
14
  (0, util_1.loadRoute)(route.name);
@@ -31,7 +31,7 @@ class HttpResponse {
31
31
  * If there are no previous URLs, redirects to the current URL.
32
32
  */
33
33
  redirectBack() {
34
- return this.response.redirect(this.request.get("Referrer") || "");
34
+ return this.response.redirect(300, this.request.get("Referrer") || "");
35
35
  }
36
36
  with(message, type) {
37
37
  this.request.flash(type, message);
@@ -1,6 +1,7 @@
1
1
  import { Application } from "../Application/Application";
2
2
  export declare class Server {
3
3
  private app;
4
+ private io?;
4
5
  constructor(app: Application);
5
6
  server(port: number): any;
6
7
  private httpErrors;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Server/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,qBAAa,MAAM;IACjB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAIrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAsChC,OAAO,CAAC,UAAU;CAKnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Server/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,qBAAa,MAAM;IACjB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,EAAE,CAAC,CAAiB;gBAEhB,GAAG,EAAE,WAAW;IAIrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAsChC,OAAO,CAAC,UAAU;CAKnB"}
@@ -1,12 +1,11 @@
1
- import { ObjectType } from "../Type";
2
1
  import { AppRequest } from "../Interface";
3
2
  /**
4
3
  * Validates form data.
5
4
  * @param {string} errorType - The type of error.
6
5
  * @param {AppRequest} req - The request object.
7
- * @param {ObjectType} formData - The form data to validate.
8
- * @returns {Promise<ObjectType>} - Validated data.
6
+ * @param {Record<string,any>} formData - The form data to validate.
7
+ * @returns {Promise<Record<string,any>>} - Validated data.
9
8
  * @throws {AppError} - Throws error if validation fails.
10
9
  */
11
- export declare const validateRequest: (errorType: string, req: AppRequest, formData: ObjectType) => Promise<ObjectType>;
10
+ export declare const validateRequest: (errorType: string, req: AppRequest, formData: Record<string, any>) => Promise<Record<string, any>>;
12
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAkE1C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,EACjB,KAAK,UAAU,EACf,UAAU,UAAU,KACnB,OAAO,CAAC,UAAU,CAUpB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Validation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAoE1C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,EACjB,KAAK,UAAU,EACf,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAU7B,CAAC"}
@@ -12,7 +12,7 @@ class Validation extends rules_1.Rules {
12
12
  /**
13
13
  * Runs validation on form data.
14
14
  * @param {AppRequest} req - The request object.
15
- * @param {ObjectType} formData - The form data to validate.
15
+ * @param {Record<string,any>} formData - The form data to validate.
16
16
  * @returns {Promise<{ errors: Record<string,any>, validateData: Record<string,any> }>} - Validation errors and validated data.
17
17
  */
18
18
  async run(req, formData = {}) {
@@ -22,7 +22,6 @@ class Validation extends rules_1.Rules {
22
22
  const rules = formData[key];
23
23
  for (const rule of rules) {
24
24
  const [validation, secondValue] = this.extractValidationAndSecondValue(rule);
25
- // Handle all validation rules uniformly
26
25
  const result = await this.validate(validation, key, req.body[key] || "", secondValue);
27
26
  if (result) {
28
27
  errors[key] = result;
@@ -52,8 +51,8 @@ class Validation extends rules_1.Rules {
52
51
  * Validates form data.
53
52
  * @param {string} errorType - The type of error.
54
53
  * @param {AppRequest} req - The request object.
55
- * @param {ObjectType} formData - The form data to validate.
56
- * @returns {Promise<ObjectType>} - Validated data.
54
+ * @param {Record<string,any>} formData - The form data to validate.
55
+ * @returns {Promise<Record<string,any>>} - Validated data.
57
56
  * @throws {AppError} - Throws error if validation fails.
58
57
  */
59
58
  const validateRequest = async (errorType, req, formData) => {
@@ -1 +1 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Validation/rules.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAqGtC,qBAAa,KAAM,SAAQ,QAAQ;IACjC;;;;;;;;OAQG;cACa,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,EACf,WAAW,GAAE,MAAW,GACvB,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC;CA+C7B"}
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Validation/rules.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,KAAM,SAAQ,QAAQ;IACjC;;;;;;;;OAQG;cACa,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,GAAG,EACf,WAAW,GAAE,MAAW,GACvB,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC;CA8C7B"}
@@ -4,78 +4,6 @@ exports.Rules = void 0;
4
4
  const AppError_1 = require("../Error/AppError");
5
5
  const error_1 = require("../Error/Constants/error");
6
6
  const validate_1 = require("./validate");
7
- // export class Rules extends Validate {
8
- // protected async validate(
9
- // validation: string,
10
- // fieldName: any,
11
- // fieldValue: any,
12
- // secondValue: string,
13
- // ) {
14
- // try {
15
- // switch (validation) {
16
- // case "required":
17
- // return this.required(fieldName, fieldValue);
18
- // case "min":
19
- // return this.min(fieldName, fieldValue, Number(secondValue));
20
- // case "max":
21
- // return this.max(fieldName, fieldValue, Number(secondValue));
22
- // case "email":
23
- // return this.email(fieldValue);
24
- // case "unique":
25
- // return await this.unique(fieldName, fieldValue, secondValue);
26
- // case "same":
27
- // return this.same(fieldName, fieldValue);
28
- // case "alpha":
29
- // return this.alpha(fieldName, fieldValue);
30
- // case "alphaNum":
31
- // return this.alphaNum(fieldName, fieldValue);
32
- // case "num":
33
- // return this.num(fieldName, fieldValue);
34
- // case "bool":
35
- // return this.bool(fieldName, fieldValue);
36
- // case "float":
37
- // return this.float(fieldName, fieldValue);
38
- // case "int":
39
- // return this.int(fieldName, fieldValue);
40
- // case "decimal":
41
- // return this.decimal(fieldName, fieldValue);
42
- // case "jwt":
43
- // return this.jwt(fieldName, fieldValue);
44
- // case "json":
45
- // return this.json(fieldName, fieldValue);
46
- // case "postal":
47
- // return this.postal(fieldName, fieldValue, secondValue);
48
- // case "slug":
49
- // return this.slug(fieldName, fieldValue);
50
- // case "url":
51
- // return this.url(fieldName, fieldValue);
52
- // case "creditCard":
53
- // return this.creditCard(fieldName, fieldValue);
54
- // case "mongoId":
55
- // return this.mongoId(fieldName, fieldValue);
56
- // case "nullable":
57
- // return this.nullable();
58
- // case "phone":
59
- // return this.phone(fieldName, fieldValue);
60
- // case "skip":
61
- // return this.skip();
62
- // case "next":
63
- // return this.skip();
64
- // case "array":
65
- // return this.array(fieldName, fieldValue);
66
- // case "object":
67
- // return this.object(fieldName, fieldValue);
68
- // default:
69
- // throw new AppError(
70
- // "${validation}() invalid method",
71
- // VALIDATION_METHOD_ERROR,
72
- // );
73
- // }
74
- // } catch (error: any) {
75
- // throw new AppError(error?.message, VALIDATION_RULE_ERROR);
76
- // }
77
- // }
78
- // }
79
7
  class Rules extends validate_1.Validate {
80
8
  /**
81
9
  * Validates a field based on the provided validation rule.
@@ -88,7 +16,6 @@ class Rules extends validate_1.Validate {
88
16
  */
89
17
  async validate(validation, fieldName, fieldValue, secondValue = "") {
90
18
  try {
91
- // Map validation rules to their corresponding methods
92
19
  const validationMethods = {
93
20
  required: () => this.required(fieldName, fieldValue),
94
21
  min: () => this.min(fieldName, fieldValue, Number(secondValue)),
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Validation/validate.ts"],"names":[],"mappings":"AAGA,8BAAsB,QAAQ;IAC5B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAMtE;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO;IAQjE;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO;IAQhE;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,CACX,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,OAAO;IAUnB;;;;;;OAMG;IACH,SAAS,CAAC,GAAG,CACX,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,OAAO;IAUnB;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAIrD;;;;;OAKG;IACH,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO;IAMpE;;;;;OAKG;IACH,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO;IAMrE;;;;;OAKG;IACH,SAAS,CAAC,GAAG,CAAC,SAAS,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AE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAMvE;;;OAGG;IACH,SAAS,CAAC,IAAI,IAAI,OAAO;IAIzB;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO;IAM1E;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG;IAI9C;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAI3D;;;;OAIG;IACH,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMpD;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAIvB;;;;OAIG;IACH,OAAO,CAAC,OAAO;CAGhB"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Validate = void 0;
7
7
  const validator_1 = __importDefault(require("validator"));
8
8
  const index_1 = require("../util/index");
9
+ const Str_1 = require("../util/Str");
9
10
  class Validate {
10
11
  /**
11
12
  * Validates if a field is required.
@@ -326,7 +327,7 @@ class Validate {
326
327
  * @returns {string} - The capitalized field name.
327
328
  */
328
329
  capitalizeField(fieldName) {
329
- return (0, index_1.capitalize)(fieldName);
330
+ return Str_1.Str.capitalize(fieldName);
330
331
  }
331
332
  /**
332
333
  * Helper method to check if a value is empty.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcc-express-mvc",
3
- "version": "1.5.5",
3
+ "version": "1.5.7",
4
4
  "description": "express mvc structure",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",