jcc-express-mvc 1.5.6 → 1.5.8
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/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/lib/Application/Application.js +1 -1
- package/lib/Auth/index.d.ts +1 -1
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Auth/index.js +3 -6
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +9 -10
- package/lib/Error/DisplayErrorCode.d.ts +3 -2
- package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
- package/lib/Error/DisplayErrorCode.js +7 -8
- package/lib/Error/ErrorHightLight.d.ts +1 -1
- package/lib/Error/ErrorHightLight.d.ts.map +1 -1
- package/lib/Error/ErrorHightLight.js +23 -8
- package/lib/Error/ErrorStyles.d.ts +7 -0
- package/lib/Error/ErrorStyles.d.ts.map +1 -0
- package/lib/Error/ErrorStyles.js +280 -0
- package/lib/Middleware/index.d.ts.map +1 -1
- package/lib/Middleware/index.js +0 -2
- package/lib/Providers/RouteServiceProvider.d.ts +1 -1
- package/lib/Providers/RouteServiceProvider.d.ts.map +1 -1
- package/lib/Providers/RouteServiceProvider.js +1 -1
- package/lib/Response/index.js +1 -1
- package/lib/Server/index.d.ts +1 -0
- package/lib/Server/index.d.ts.map +1 -1
- package/lib/Validation/index.d.ts +3 -4
- package/lib/Validation/index.d.ts.map +1 -1
- package/lib/Validation/index.js +3 -4
- package/lib/Validation/rules.d.ts.map +1 -1
- package/lib/Validation/rules.js +1 -74
- package/lib/Validation/validate.d.ts.map +1 -1
- package/lib/Validation/validate.js +3 -1
- package/package.json +1 -1
- package/lib/Error/public/css/app-error-prism-line.css +0 -71
- package/lib/Error/public/css/app-error-prism.css +0 -99
- package/lib/Error/public/css/app-error.css +0 -64
- package/lib/Error/public/error.html +0 -130
- package/lib/Error/public/js/app-error-prism-line.js +0 -377
- package/lib/Error/public/js/app-error-prism.js +0 -7
- package/lib/Error/public/pageNotFound.html +0 -28
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":"
|
|
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
|
}
|
package/lib/Auth/index.d.ts
CHANGED
|
@@ -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
|
package/lib/Auth/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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;
|
|
1
|
+
{"version":3,"file":"AppErrorHandler.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Error/AppErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,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) {
|
|
@@ -30,12 +30,12 @@ class AppErrorHandler {
|
|
|
30
30
|
const parts = lastError.split(/\s/g);
|
|
31
31
|
return parts[parts.length - 1];
|
|
32
32
|
}
|
|
33
|
+
if (index >= 5 || !stackArray[index]) {
|
|
34
|
+
return "Internal server error";
|
|
35
|
+
}
|
|
33
36
|
const currentError = stackArray[index];
|
|
34
37
|
const parts = currentError.split(/\s/g);
|
|
35
38
|
const errorPath = parts[parts.length - 1];
|
|
36
|
-
if (index >= 5) {
|
|
37
|
-
return "Internal server error";
|
|
38
|
-
}
|
|
39
39
|
if (!this.isPath(errorPath)) {
|
|
40
40
|
return this.extractErrorPath(stackArray, true, index + 1);
|
|
41
41
|
}
|
|
@@ -55,14 +55,13 @@ 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);
|
|
65
|
-
|
|
61
|
+
let erorrContent = DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res, req);
|
|
62
|
+
return res.status(500).send(erorrContent);
|
|
63
|
+
//
|
|
64
|
+
// return DisplayError.show(errorPath, err.message, res, req);
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
}
|
|
@@ -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:
|
|
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(
|
|
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;
|
|
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;IA0CjB;;;;;;;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,8 @@ 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.
|
|
24
|
+
if (req.headers["content-type"] == "application/json" &&
|
|
25
|
+
!req.headers["x-inertia"]) {
|
|
26
26
|
return res.status(500).json({
|
|
27
27
|
stack: pathParts.join("/").trim() + ` on line ${startLine}:${endLine}`,
|
|
28
28
|
error: ` ${message} `,
|
|
@@ -33,7 +33,9 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
|
|
|
33
33
|
let formattedContent = content
|
|
34
34
|
.map((line, index) => `${index + 1}. ${line}`)
|
|
35
35
|
.join("\n");
|
|
36
|
-
return this.renderHtml(
|
|
36
|
+
return this.renderHtml(formattedContent, startLine, `<p class='py-2 text-red'>${message.trim()}</p> <p class='p-2 text-sm'> ${pathParts
|
|
37
|
+
.join("/")
|
|
38
|
+
.trim()} ${startLine}:${endLine} </p>`);
|
|
37
39
|
}
|
|
38
40
|
catch (error) {
|
|
39
41
|
return res
|
|
@@ -49,11 +51,8 @@ class DisplayError extends ErrorHightLight_1.ErrorHighLighter {
|
|
|
49
51
|
* @param message The error message to display.
|
|
50
52
|
* @returns The HTML response.
|
|
51
53
|
*/
|
|
52
|
-
static renderHtml(
|
|
53
|
-
this.compileCodeToFile(code, line, message);
|
|
54
|
-
return res
|
|
55
|
-
.status(500)
|
|
56
|
-
.sendFile(path_1.default.join(__dirname, "public", "error.html"));
|
|
54
|
+
static renderHtml(code, line, message) {
|
|
55
|
+
return this.compileCodeToFile(code, line, message);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
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):
|
|
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":"
|
|
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;IAkDjB;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;CAO3E"}
|
|
@@ -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.
|
|
@@ -14,18 +16,15 @@ class ErrorHighLighter {
|
|
|
14
16
|
* @returns The HTML string for the error display.
|
|
15
17
|
*/
|
|
16
18
|
static generateHtmlCode(code, line, message) {
|
|
17
|
-
// <link rel="stylesheet" href="/css/main.css" />
|
|
18
19
|
return `
|
|
19
20
|
<!DOCTYPE html>
|
|
20
21
|
<html lang="en">
|
|
21
22
|
<head>
|
|
22
23
|
<meta charset="UTF-8" />
|
|
23
24
|
<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
25
|
<title>Error</title>
|
|
28
|
-
|
|
26
|
+
<style>
|
|
27
|
+
${ErrorStyles_1.ErrorStyles.styles()}
|
|
29
28
|
</style>
|
|
30
29
|
</head>
|
|
31
30
|
<body class="">
|
|
@@ -37,11 +36,27 @@ class ErrorHighLighter {
|
|
|
37
36
|
<pre
|
|
38
37
|
data-line="${line}"
|
|
39
38
|
class="line-numbers"
|
|
39
|
+
id="error-line"
|
|
40
40
|
><code class="language-javascript">${code}</code></pre>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
|
-
<script
|
|
44
|
-
|
|
43
|
+
<script>
|
|
44
|
+
${fs_1.default
|
|
45
|
+
.readFileSync(path_1.default.join(__dirname, "public/js", "app-error-prism.js"))
|
|
46
|
+
.toString()}
|
|
47
|
+
|
|
48
|
+
${fs_1.default
|
|
49
|
+
.readFileSync(path_1.default.join(__dirname, "public/js", "app-error-prism-line.js"))
|
|
50
|
+
.toString()}
|
|
51
|
+
|
|
52
|
+
window.onload = function () {
|
|
53
|
+
const errorLine = document.getElementById("error-line");
|
|
54
|
+
if (errorLine) {
|
|
55
|
+
errorLine.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
</script>
|
|
45
60
|
</body>
|
|
46
61
|
</html>
|
|
47
62
|
`;
|
|
@@ -54,7 +69,7 @@ class ErrorHighLighter {
|
|
|
54
69
|
*/
|
|
55
70
|
static compileCodeToFile(code, line, message) {
|
|
56
71
|
try {
|
|
57
|
-
return
|
|
72
|
+
return this.generateHtmlCode(code, line, message);
|
|
58
73
|
}
|
|
59
74
|
catch (error) {
|
|
60
75
|
console.log(error.message);
|
|
@@ -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;IA2F/B,OAAO,CAAC,MAAM,CAAC,UAAU;IAsGzB,OAAO,CAAC,MAAM,CAAC,cAAc;IA6E7B,MAAM,CAAC,MAAM;CAOd"}
|
|
@@ -0,0 +1,280 @@
|
|
|
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
|
+
html {
|
|
13
|
+
scroll-behavior: smooth;
|
|
14
|
+
}
|
|
15
|
+
body {
|
|
16
|
+
background: #0e0f1d;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
height: 100vh;
|
|
21
|
+
width: 100%;
|
|
22
|
+
font-family: "BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica,
|
|
23
|
+
Arial, sans-serif;
|
|
24
|
+
}
|
|
25
|
+
.code-container {
|
|
26
|
+
background: #151b23;
|
|
27
|
+
padding: 10px 0;
|
|
28
|
+
min-height: 60vh;
|
|
29
|
+
max-height: 90vh;
|
|
30
|
+
}
|
|
31
|
+
.code-container::-webkit-scrollbar {
|
|
32
|
+
width: 1px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.code-container::-webkit-scrollbar-track {
|
|
36
|
+
background: #f1f1f1; /* Track color */
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.code-container::-webkit-scrollbar-thumb {
|
|
40
|
+
background-color: #888; /* Handle color */
|
|
41
|
+
border-radius: 10px; /* Rounded corners for handle */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.code-container::-webkit-scrollbar-thumb:hover {
|
|
45
|
+
background-color: #555; /* Color when hovered */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.error-message {
|
|
49
|
+
color: #fff; /*rgba(245, 43, 43, 0.897);*/
|
|
50
|
+
padding: 20px;
|
|
51
|
+
width: 100%;
|
|
52
|
+
font-size: 1.3rem;
|
|
53
|
+
border-bottom: 1px solid #ddd;
|
|
54
|
+
error-message
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.py-2{
|
|
58
|
+
padding: 10px 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.text-red {
|
|
62
|
+
color:rgb(224, 31, 31);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.text-sm{
|
|
66
|
+
font-size: 1.2rem
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.p-2{
|
|
70
|
+
padding: 10px 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@media (min-width: 640px) {
|
|
74
|
+
.code-container {
|
|
75
|
+
min-width: 50%;
|
|
76
|
+
max-width: 80%;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (min-width: 768px) {
|
|
81
|
+
.code-container {
|
|
82
|
+
min-width: 50%;
|
|
83
|
+
max-width: 80%;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
@media (min-width: 1024px) {
|
|
87
|
+
.code-container {
|
|
88
|
+
min-width: 50%;
|
|
89
|
+
max-width: 60%;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
static prismStyle() {
|
|
96
|
+
return `
|
|
97
|
+
code[class*="language-"],
|
|
98
|
+
pre[class*="language-"] {
|
|
99
|
+
color: #f8f8f2;
|
|
100
|
+
background: 0 0;
|
|
101
|
+
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
|
102
|
+
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
|
|
103
|
+
font-size: 1em;
|
|
104
|
+
text-align: left;
|
|
105
|
+
white-space: pre;
|
|
106
|
+
word-spacing: normal;
|
|
107
|
+
word-break: normal;
|
|
108
|
+
word-wrap: normal;
|
|
109
|
+
line-height: 1.5;
|
|
110
|
+
-moz-tab-size: 4;
|
|
111
|
+
-o-tab-size: 4;
|
|
112
|
+
tab-size: 4;
|
|
113
|
+
-webkit-hyphens: none;
|
|
114
|
+
-moz-hyphens: none;
|
|
115
|
+
-ms-hyphens: none;
|
|
116
|
+
hyphens: none;
|
|
117
|
+
}
|
|
118
|
+
pre[class*="language-"] {
|
|
119
|
+
padding: 1em;
|
|
120
|
+
overflow: auto;
|
|
121
|
+
border-radius: 0.3em;
|
|
122
|
+
}
|
|
123
|
+
:not(pre) > code[class*="language-"],
|
|
124
|
+
pre[class*="language-"] {
|
|
125
|
+
background: #10151bd0;
|
|
126
|
+
}
|
|
127
|
+
:not(pre) > code[class*="language-"] {
|
|
128
|
+
padding: 0.1em;
|
|
129
|
+
border-radius: 0.3em;
|
|
130
|
+
white-space: normal;
|
|
131
|
+
}
|
|
132
|
+
.token.cdata,
|
|
133
|
+
.token.comment,
|
|
134
|
+
.token.doctype,
|
|
135
|
+
.token.prolog {
|
|
136
|
+
color: #8292a2;
|
|
137
|
+
}
|
|
138
|
+
.token.punctuation {
|
|
139
|
+
color: #cc872d;
|
|
140
|
+
}
|
|
141
|
+
.token.namespace {
|
|
142
|
+
opacity: 0.7;
|
|
143
|
+
}
|
|
144
|
+
.token.constant,
|
|
145
|
+
.token.deleted,
|
|
146
|
+
.token.property,
|
|
147
|
+
.token.symbol,
|
|
148
|
+
.token.tag {
|
|
149
|
+
color: #0786fd;
|
|
150
|
+
}
|
|
151
|
+
.token.boolean,
|
|
152
|
+
.token.number {
|
|
153
|
+
color: #767c83;
|
|
154
|
+
}
|
|
155
|
+
.token.attr-name,
|
|
156
|
+
.token.builtin,
|
|
157
|
+
.token.char,
|
|
158
|
+
.token.inserted,
|
|
159
|
+
.token.selector,
|
|
160
|
+
.token.string {
|
|
161
|
+
color: #07db43e1;
|
|
162
|
+
}
|
|
163
|
+
.language-css .token.string,
|
|
164
|
+
.style .token.string,
|
|
165
|
+
.token.entity,
|
|
166
|
+
.token.operator,
|
|
167
|
+
.token.url,
|
|
168
|
+
.token.variable {
|
|
169
|
+
color: #f8f8f2;
|
|
170
|
+
}
|
|
171
|
+
.token.atrule,
|
|
172
|
+
.token.attr-value,
|
|
173
|
+
.token.class-name,
|
|
174
|
+
.token.function {
|
|
175
|
+
color: #cf74e6;
|
|
176
|
+
}
|
|
177
|
+
.token.keyword {
|
|
178
|
+
color: #e22d2d;
|
|
179
|
+
}
|
|
180
|
+
.token.important,
|
|
181
|
+
.token.regex {
|
|
182
|
+
color: #fd971f;
|
|
183
|
+
}
|
|
184
|
+
.token.bold,
|
|
185
|
+
.token.important {
|
|
186
|
+
font-weight: 700;
|
|
187
|
+
}
|
|
188
|
+
.token.italic {
|
|
189
|
+
font-style: italic;
|
|
190
|
+
}
|
|
191
|
+
.token.entity {
|
|
192
|
+
cursor: help;
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
static prismLineStyle() {
|
|
197
|
+
return `
|
|
198
|
+
pre[data-line] {
|
|
199
|
+
position: relative;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.line-highlight {
|
|
203
|
+
position: absolute;
|
|
204
|
+
left: 0;
|
|
205
|
+
right: 0;
|
|
206
|
+
padding: inherit 0;
|
|
207
|
+
margin-top: 0.8rem;
|
|
208
|
+
/* Same as .prism’s padding-top */
|
|
209
|
+
|
|
210
|
+
background: hsla(2, 93%, 47%, 0.329);
|
|
211
|
+
background: linear-gradient(
|
|
212
|
+
to right,
|
|
213
|
+
hsla(2, 93%, 47%, 0.329) 70%,
|
|
214
|
+
hsla(2, 93%, 47%, 0.329)
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
/* border-bottom: 2px dashed rgb(221, 24, 24); */
|
|
218
|
+
pointer-events: none;
|
|
219
|
+
|
|
220
|
+
line-height: inherit;
|
|
221
|
+
white-space: pre;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@media print {
|
|
225
|
+
.line-highlight {
|
|
226
|
+
-webkit-print-color-adjust: exact;
|
|
227
|
+
color-adjust: exact;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.line-highlight:before,
|
|
232
|
+
.line-highlight[data-end]:after {
|
|
233
|
+
content: attr(data-start);
|
|
234
|
+
position: absolute;
|
|
235
|
+
top: 0.4em;
|
|
236
|
+
left: 0.6em;
|
|
237
|
+
min-width: 1em;
|
|
238
|
+
padding: 0 0.5em;
|
|
239
|
+
background-color: hsla(24, 20%, 50%, 0.4);
|
|
240
|
+
color: hsl(24, 20%, 95%);
|
|
241
|
+
font: bold 65%/1.5 sans-serif;
|
|
242
|
+
text-align: center;
|
|
243
|
+
vertical-align: 0.3em;
|
|
244
|
+
border-radius: 999px;
|
|
245
|
+
text-shadow: none;
|
|
246
|
+
box-shadow: 0 1px white;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.line-highlight[data-end]:after {
|
|
250
|
+
content: attr(data-end);
|
|
251
|
+
top: auto;
|
|
252
|
+
bottom: 0.4em;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.line-numbers .line-highlight:before,
|
|
256
|
+
.line-numbers .line-highlight:after {
|
|
257
|
+
content: none;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
pre[id].linkable-line-numbers span.line-numbers-rows {
|
|
261
|
+
pointer-events: all;
|
|
262
|
+
}
|
|
263
|
+
pre[id].linkable-line-numbers span.line-numbers-rows > span:before {
|
|
264
|
+
cursor: pointer;
|
|
265
|
+
}
|
|
266
|
+
pre[id].linkable-line-numbers span.line-numbers-rows > span:hover:before {
|
|
267
|
+
background-color: rgba(128, 128, 128, 0.2);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
`;
|
|
271
|
+
}
|
|
272
|
+
static styles() {
|
|
273
|
+
return `
|
|
274
|
+
${this.prismStyle()}
|
|
275
|
+
${this.prismLineStyle()}
|
|
276
|
+
${this.customErrorStyle()}
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
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;
|
|
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"}
|
package/lib/Middleware/index.js
CHANGED
|
@@ -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;
|
|
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);
|
package/lib/Response/index.js
CHANGED
|
@@ -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);
|
package/lib/Server/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Framework/lib/Server/index.ts"],"names":[],"mappings":"
|
|
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 {
|
|
8
|
-
* @returns {Promise<
|
|
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:
|
|
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":"
|
|
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"}
|