jcc-express-mvc 1.3.10 → 1.3.12
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/Dependency.d.ts +2 -0
- package/Dependency.d.ts.map +1 -0
- package/Dependency.js +17 -0
- package/cli.d.ts +1 -0
- package/cli.d.ts.map +1 -1
- package/cli.js +1 -0
- package/lib/App.d.ts +2 -1
- package/lib/App.d.ts.map +1 -1
- package/lib/Command-Line/DBCommand.d.ts.map +1 -1
- package/lib/Command-Line/DBCommand.js +1 -3
- package/lib/Command-Line/MakeCommand.d.ts.map +1 -1
- package/lib/Command-Line/MakeCommand.js +3 -7
- package/lib/Command-Line/MigrateCommand.d.ts +1 -1
- package/lib/Command-Line/MigrateCommand.d.ts.map +1 -1
- package/lib/Command-Line/MigrateCommand.js +10 -3
- package/lib/Command-Line/NodeArtisanCommand.d.ts +1 -6
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +24 -31
- package/lib/Command-Line/NodeTinker/ConsoleInput.d.ts +2 -0
- package/lib/Command-Line/NodeTinker/ConsoleInput.d.ts.map +1 -0
- package/lib/Command-Line/NodeTinker/ConsoleInput.js +30 -0
- package/lib/Command-Line/NodeTinker/Tinker.d.ts +18 -0
- package/lib/Command-Line/NodeTinker/Tinker.d.ts.map +1 -0
- package/lib/Command-Line/NodeTinker/Tinker.js +56 -0
- package/lib/Command-Line/NodeTinker/TinkerCommand.d.ts +5 -0
- package/lib/Command-Line/NodeTinker/TinkerCommand.d.ts.map +1 -0
- package/lib/Command-Line/NodeTinker/TinkerCommand.js +17 -0
- package/lib/Command-Line/command.d.ts +1 -1
- package/lib/Command-Line/command.d.ts.map +1 -1
- package/lib/Command-Line/command.js +5 -8
- package/lib/Dependancy/index.d.ts +4 -0
- package/lib/Dependancy/index.d.ts.map +1 -0
- package/lib/Dependancy/index.js +24 -0
- package/lib/Error/AppError.d.ts +2 -2
- package/lib/Error/AppError.d.ts.map +1 -1
- package/lib/Error/AppError.js +2 -2
- package/lib/Error/AppErrorHandler.d.ts +7 -1
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +37 -6
- package/lib/Error/DisplayErrorCode.d.ts +18 -3
- package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
- package/lib/Error/DisplayErrorCode.js +41 -32
- package/lib/Error/ErrorHightLight.d.ts +18 -0
- package/lib/Error/ErrorHightLight.d.ts.map +1 -0
- package/lib/Error/ErrorHightLight.js +64 -0
- package/lib/Error/public/css/app-error-prism-line.css +71 -0
- package/lib/Error/public/css/app-error-prism.css +99 -0
- package/lib/Error/public/css/app-error.css +64 -0
- package/lib/Error/public/error.html +26 -105
- package/lib/Error/public/js/app-error-prism-line.js +377 -0
- package/lib/Error/public/js/app-error-prism.js +7 -0
- package/lib/Middlewares/index.d.ts.map +1 -1
- package/lib/Middlewares/index.js +2 -0
- package/lib/Routes/RouteBuilder.d.ts +4 -1
- package/lib/Routes/RouteBuilder.d.ts.map +1 -1
- package/lib/Routes/RouteBuilder.js +26 -12
- package/lib/Services/ServiceContainer.d.ts +2 -0
- package/lib/Services/ServiceContainer.d.ts.map +1 -1
- package/lib/Services/ServiceContainer.js +13 -0
- package/lib/Type/index.d.ts +1 -0
- package/lib/Type/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/Error/ErrorHigtlig.d.ts +0 -5
- package/lib/Error/ErrorHigtlig.d.ts.map +0 -1
- package/lib/Error/ErrorHigtlig.js +0 -95
package/Dependency.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dependency.d.ts","sourceRoot":"","sources":["../framework/Dependency.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
package/Dependency.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib/Dependancy"), exports);
|
package/cli.d.ts
CHANGED
package/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../framework/cli.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../framework/cli.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC"}
|
package/cli.js
CHANGED
|
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./lib/Command-Line/NodeArtisanCommand"), exports);
|
|
18
|
+
__exportStar(require("./lib/Command-Line/NodeTinker/ConsoleInput"), exports);
|
package/lib/App.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Router } from "./Routes/Router";
|
|
2
2
|
import { HttpSever } from "./Server";
|
|
3
|
+
import { ServiceContainer } from "./Services/ServiceContainer";
|
|
3
4
|
declare class App extends HttpSever {
|
|
4
|
-
|
|
5
|
+
container: ServiceContainer;
|
|
5
6
|
constructor();
|
|
6
7
|
private initiateProviders;
|
|
7
8
|
webRoutes(): Router<any>;
|
package/lib/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../framework/lib/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../framework/lib/App.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,cAAM,GAAI,SAAQ,SAAS;IAGlB,SAAS,mBAA0B;;IAS1C,OAAO,CAAC,iBAAiB;IAQlB,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC;IAQ/B;;;OAGG;IACI,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC;IAQ/B;;;OAGG;IACI,UAAU,IAAI,GAAG;CAYzB;AAED,eAAO,MAAM,GAAG,KAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/DBCommand.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,gBAAsB,KAAK,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"DBCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/DBCommand.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,gBAAsB,KAAK,CAAC,GAAG,CAAC,kBAoCrD,CAAC"}
|
|
@@ -11,7 +11,7 @@ const DBCommand = async (commandArg = []) => {
|
|
|
11
11
|
try {
|
|
12
12
|
const migrationPath = `${rootPath}/database/seeders`;
|
|
13
13
|
let index = commandArg.findIndex((arg) => arg.includes(":"));
|
|
14
|
-
const [command, type] = commandArg[index].split(/\:/g);
|
|
14
|
+
// const [command, type] = commandArg[index].split(/\:/g);
|
|
15
15
|
//If console the is db:seed with the class like --class=ClassName
|
|
16
16
|
const option = commandArg[index + 1] || "";
|
|
17
17
|
if (option && option.includes("=")) {
|
|
@@ -33,11 +33,9 @@ const DBCommand = async (commandArg = []) => {
|
|
|
33
33
|
console.log(colors_1.default.green(`${Seeder?.name} successfully seeded`.replace(/(\{|\})/g, "")));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
return process.exit(0);
|
|
37
36
|
}
|
|
38
37
|
catch (error) {
|
|
39
38
|
console.log(error.message);
|
|
40
|
-
return process.exit(0);
|
|
41
39
|
}
|
|
42
40
|
};
|
|
43
41
|
exports.DBCommand = DBCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,gBAAgB,KAAK,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,gBAAgB,KAAK,CAAC,GAAG,CAAC,QAgGjD,CAAC"}
|
|
@@ -8,10 +8,6 @@ const command_1 = __importDefault(require("./command"));
|
|
|
8
8
|
const makeCommand = (commandArg = []) => {
|
|
9
9
|
let index = commandArg.findIndex((arg, index) => arg.includes(":")); //commandArg[0].split(":")[1] || commandArg[1].split(":")[1]; // Extract the command type from the first argument
|
|
10
10
|
let command = commandArg[index].split(":")[1] || "";
|
|
11
|
-
// If the command is for creating an API controller with resources
|
|
12
|
-
if (command.trim() === "migrate") {
|
|
13
|
-
return command_1.default.runMigration();
|
|
14
|
-
}
|
|
15
11
|
if (commandArg.length === index + 4 &&
|
|
16
12
|
(command === "apiController" || command === "ApiController") &&
|
|
17
13
|
(commandArg[index + 3] === "--resources" || commandArg[index + 3] === "-r")) {
|
|
@@ -57,9 +53,9 @@ const makeCommand = (commandArg = []) => {
|
|
|
57
53
|
return command_1.default.addRequest(commandArg[index + 1]); // Add a request file
|
|
58
54
|
}
|
|
59
55
|
// If the command is for creating a Migration file
|
|
60
|
-
if (commandArg.length === index + 2 ||
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
if (((commandArg.length === index + 2 || commandArg.length === index + 3) &&
|
|
57
|
+
command === "Migration") ||
|
|
58
|
+
command === "migration") {
|
|
63
59
|
const tableOptional = commandArg[index + 2] || ""; // --table=user
|
|
64
60
|
const optionalTable = tableOptional.includes("=")
|
|
65
61
|
? tableOptional.split(/\=/g)[1]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const migrateCommand: (commandArg?: Array<any>) => Promise<any>;
|
|
1
|
+
export declare const migrateCommand: (actionType: string, type?: string, commandArg?: Array<any>) => Promise<any>;
|
|
2
2
|
//# sourceMappingURL=MigrateCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/MigrateCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/MigrateCommand.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,eACb,MAAM,SACZ,MAAM,eACA,KAAK,CAAC,GAAG,CAAC,iBAkCvB,CAAC"}
|
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.migrateCommand = void 0;
|
|
7
7
|
const jcc_eloquent_1 = require("jcc-eloquent");
|
|
8
8
|
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
9
|
+
const command_1 = __importDefault(require("./command"));
|
|
9
10
|
const rootPath = app_root_path_1.default.path;
|
|
10
|
-
const migrateCommand = async (commandArg = []) => {
|
|
11
|
+
const migrateCommand = async (actionType, type = "", commandArg = []) => {
|
|
11
12
|
const migrationPath = `${rootPath}/database/migrations`;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
if (actionType?.trim() === "migrate" && !type) {
|
|
14
|
+
return command_1.default.runMigration();
|
|
15
|
+
}
|
|
14
16
|
if (type?.trim() === "rollback") {
|
|
17
|
+
let index = commandArg.findIndex((arg) => arg.includes(":"));
|
|
15
18
|
let arg = commandArg[index + 1];
|
|
16
19
|
if (arg && arg?.trim() === "reset") {
|
|
17
20
|
const steps = await jcc_eloquent_1.Model.select().from("migrations").count();
|
|
@@ -30,5 +33,9 @@ const migrateCommand = async (commandArg = []) => {
|
|
|
30
33
|
await jcc_eloquent_1.DB.rollback(steps, migrationPath);
|
|
31
34
|
return jcc_eloquent_1.DB.migrate(migrationPath);
|
|
32
35
|
}
|
|
36
|
+
if (type.trim() === "reset") {
|
|
37
|
+
const steps = await jcc_eloquent_1.Model.select().from("migrations").count();
|
|
38
|
+
return jcc_eloquent_1.DB.rollback(steps, migrationPath);
|
|
39
|
+
}
|
|
33
40
|
};
|
|
34
41
|
exports.migrateCommand = migrateCommand;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Function to parse command line arguments and execute corresponding commands
|
|
3
|
-
@param {commandArg} commandArg -string
|
|
4
|
-
@returns {any} -any
|
|
5
|
-
* */
|
|
6
|
-
export declare const NodeArtisanCommand: (commandArg?: Array<any>) => any;
|
|
1
|
+
export declare const getArgv: (consoleArgs: Array<any>) => Promise<void>;
|
|
7
2
|
//# sourceMappingURL=NodeArtisanCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,OAAO,gBA/BO,KAAK,CAAC,GAAG,CAAC,kBA+BqC,CAAC"}
|
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
3
|
+
exports.getArgv = void 0;
|
|
7
4
|
const DBCommand_1 = require("./DBCommand");
|
|
8
5
|
const MakeCommand_1 = require("./MakeCommand");
|
|
9
6
|
const MigrateCommand_1 = require("./MigrateCommand");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
switch (
|
|
21
|
-
case "make":
|
|
22
|
-
return (0, MakeCommand_1.makeCommand)(commandArg);
|
|
7
|
+
class ConsoleKernel {
|
|
8
|
+
//
|
|
9
|
+
async parse(consoleArgs) {
|
|
10
|
+
const index = consoleArgs.findIndex((arg) => arg.includes(":"));
|
|
11
|
+
const [actionType, action] = index < 0
|
|
12
|
+
? [consoleArgs[consoleArgs.length - 1]]
|
|
13
|
+
: consoleArgs[index].split(/\:/g);
|
|
14
|
+
return await this.getAction(actionType, action, consoleArgs);
|
|
15
|
+
}
|
|
16
|
+
async getAction(actionType, type = "", argvs) {
|
|
17
|
+
switch (actionType) {
|
|
23
18
|
case "migrate":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
.catch((err) => console.log(err))
|
|
27
|
-
.finally(() => process.exit(0));
|
|
19
|
+
await (0, MigrateCommand_1.migrateCommand)(actionType, type, argvs);
|
|
20
|
+
return;
|
|
28
21
|
case "db":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
await (0, DBCommand_1.DBCommand)(argvs);
|
|
23
|
+
return;
|
|
24
|
+
case "make":
|
|
25
|
+
const data = await (0, MakeCommand_1.makeCommand)(argvs);
|
|
26
|
+
console.log(data);
|
|
27
|
+
return;
|
|
33
28
|
default:
|
|
34
|
-
|
|
29
|
+
console.log("Sorry command not found");
|
|
30
|
+
return;
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
exports.NodeArtisanCommand = NodeArtisanCommand;
|
|
33
|
+
}
|
|
34
|
+
exports.getArgv = new ConsoleKernel().parse.bind(new ConsoleKernel());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleInput.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Command-Line/NodeTinker/ConsoleInput.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,YAsBxB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.consoleInput = void 0;
|
|
7
|
+
const TinkerCommand_1 = require("./TinkerCommand");
|
|
8
|
+
const readline_1 = __importDefault(require("readline"));
|
|
9
|
+
const consoleInput = () => {
|
|
10
|
+
const rl = readline_1.default.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout,
|
|
13
|
+
prompt: "> ",
|
|
14
|
+
});
|
|
15
|
+
rl.prompt();
|
|
16
|
+
rl.on("line", (inputLine) => {
|
|
17
|
+
const [command, ...args] = inputLine.trim().split(" ");
|
|
18
|
+
const tc = new TinkerCommand_1.TinkerCommand();
|
|
19
|
+
tc.extractCommand(command)
|
|
20
|
+
.then((res) => console.log(res))
|
|
21
|
+
.catch((err) => console.log(err));
|
|
22
|
+
return rl.prompt();
|
|
23
|
+
});
|
|
24
|
+
rl.on("close", () => {
|
|
25
|
+
console.log("Goodbye, Have a nice day.");
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
return;
|
|
29
|
+
};
|
|
30
|
+
exports.consoleInput = consoleInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class TinkerNode {
|
|
2
|
+
private regex;
|
|
3
|
+
getModel(): void;
|
|
4
|
+
/**
|
|
5
|
+
* sanitize user input
|
|
6
|
+
* @param input
|
|
7
|
+
* @returns string
|
|
8
|
+
*/
|
|
9
|
+
private sanitizedInput;
|
|
10
|
+
/**
|
|
11
|
+
* input validator
|
|
12
|
+
* @param input
|
|
13
|
+
* @returns {object}
|
|
14
|
+
*/
|
|
15
|
+
private validatedInput;
|
|
16
|
+
extractCommand(input: string): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Tinker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tinker.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Command-Line/NodeTinker/Tinker.ts"],"names":[],"mappings":"AACA,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA+C;IAE5D,QAAQ;IAER;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAItB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAehB,cAAc,CAAC,KAAK,EAAE,MAAM;CAuBnC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TinkerNode = void 0;
|
|
4
|
+
const util_1 = require("../../util");
|
|
5
|
+
class TinkerNode {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.regex = /[^\s{}()\[\]\(\)0-9a-zA-Z',_.:@]/g;
|
|
8
|
+
}
|
|
9
|
+
getModel() { }
|
|
10
|
+
/**
|
|
11
|
+
* sanitize user input
|
|
12
|
+
* @param input
|
|
13
|
+
* @returns string
|
|
14
|
+
*/
|
|
15
|
+
sanitizedInput(input) {
|
|
16
|
+
return input.replace(this.regex, "");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* input validator
|
|
20
|
+
* @param input
|
|
21
|
+
* @returns {object}
|
|
22
|
+
*/
|
|
23
|
+
validatedInput(input) {
|
|
24
|
+
const sanitizedInputData = this.sanitizedInput(input);
|
|
25
|
+
if (sanitizedInputData !== input) {
|
|
26
|
+
throw new Error("Input contains disallowed characters.");
|
|
27
|
+
}
|
|
28
|
+
const data = input.split(".");
|
|
29
|
+
if (data.length <= 1) {
|
|
30
|
+
throw new Error(`Invalid query: ${input}`);
|
|
31
|
+
}
|
|
32
|
+
const model = data[0];
|
|
33
|
+
data.splice(0, 1);
|
|
34
|
+
return { model, methods: data.join(".") };
|
|
35
|
+
}
|
|
36
|
+
async extractCommand(input) {
|
|
37
|
+
try {
|
|
38
|
+
const { model, methods } = this.validatedInput(input);
|
|
39
|
+
const queryFunction = new Function("getModel", `
|
|
40
|
+
const importedModel= getModel('${model}')
|
|
41
|
+
const m = Object.keys(importedModel)
|
|
42
|
+
|
|
43
|
+
const modelName = importedModel[m[0]];
|
|
44
|
+
|
|
45
|
+
return modelName.${methods}
|
|
46
|
+
|
|
47
|
+
`);
|
|
48
|
+
// this.connect();
|
|
49
|
+
return queryFunction(util_1.getModel);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return console.error("Error " + error?.message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TinkerNode = TinkerNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TinkerCommand.d.ts","sourceRoot":"","sources":["../../../../framework/lib/Command-Line/NodeTinker/TinkerCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,qBAAa,aAAc,SAAQ,UAAU;IAC9B,UAAU,CAAC,OAAO,EAAE,MAAM;CAYxC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TinkerCommand = void 0;
|
|
4
|
+
const Tinker_1 = require("./Tinker");
|
|
5
|
+
class TinkerCommand extends Tinker_1.TinkerNode {
|
|
6
|
+
async getCommand(command) {
|
|
7
|
+
switch (command) {
|
|
8
|
+
case "quit":
|
|
9
|
+
process.exit(0);
|
|
10
|
+
case "exit":
|
|
11
|
+
process.exit(0);
|
|
12
|
+
default:
|
|
13
|
+
return this.extractCommand(command);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.TinkerCommand = TinkerCommand;
|
|
@@ -5,7 +5,7 @@ declare class Command {
|
|
|
5
5
|
addRequest(requestName: string): any;
|
|
6
6
|
addMigration(migrationName: string, optionalTable: string): any;
|
|
7
7
|
addSeeder(name: string): any;
|
|
8
|
-
runMigration():
|
|
8
|
+
runMigration(): Promise<any>;
|
|
9
9
|
rollback(steps?: number): void;
|
|
10
10
|
notFound(): any;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/command.ts"],"names":[],"mappings":"AAeA,cAAM,OAAO;IAGX,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IA2BtD,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IA+BtD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG;IAehC,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG;IAqBpC,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG;IAyB/D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../framework/lib/Command-Line/command.ts"],"names":[],"mappings":"AAeA,cAAM,OAAO;IAGX,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IA2BtD,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IA+BtD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG;IAehC,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG;IAqBpC,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG;IAyB/D,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IAqBtB,YAAY;IASlB,QAAQ,CAAC,KAAK,GAAE,MAAU;IAU1B,QAAQ,IAAI,GAAG;CAGhB;;AAED,wBAA6B"}
|
|
@@ -114,13 +114,13 @@ class Command {
|
|
|
114
114
|
// Method to add a migration file
|
|
115
115
|
addSeeder(name) {
|
|
116
116
|
try {
|
|
117
|
-
let
|
|
117
|
+
let seederPath = path_1.default.resolve(`${rootPath}/database/seeders`);
|
|
118
118
|
// Resolve path to request files directory
|
|
119
|
-
if (fs_1.default.existsSync(`${
|
|
119
|
+
if (fs_1.default.existsSync(`${seederPath}/${name}.ts`)) {
|
|
120
120
|
// Check if request file already exists
|
|
121
121
|
return console.log(colors_1.default.yellow(`${name} already exist`)); // Log a warning if request file already exists
|
|
122
122
|
}
|
|
123
|
-
fs_1.default.writeFileSync(`${
|
|
123
|
+
fs_1.default.writeFileSync(`${seederPath}/${name}.ts`, (0, Seeder_1.default)(name));
|
|
124
124
|
return console.log(colors_1.default.green(`${name} added successfully`)); // Log success message
|
|
125
125
|
}
|
|
126
126
|
catch (err) {
|
|
@@ -129,13 +129,10 @@ class Command {
|
|
|
129
129
|
}); // Log error if request addition fails
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
runMigration() {
|
|
132
|
+
async runMigration() {
|
|
133
133
|
try {
|
|
134
134
|
const migrationPath = `${rootPath}/database/migrations`;
|
|
135
|
-
jcc_eloquent_1.DB.migrate(migrationPath)
|
|
136
|
-
.then()
|
|
137
|
-
.catch((err) => console.log(err))
|
|
138
|
-
.finally(() => process.exit(0));
|
|
135
|
+
return jcc_eloquent_1.DB.migrate(migrationPath);
|
|
139
136
|
}
|
|
140
137
|
catch (error) {
|
|
141
138
|
console.log(error.message);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../framework/lib/Dependancy/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAG1B,wBAAgB,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAc/D;AAED,wBAAgB,UAAU,CAAC,SAAS,GAAE,OAAe,GAAG,cAAc,CAOrE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Inject = Inject;
|
|
4
|
+
exports.Injectable = Injectable;
|
|
5
|
+
const App_1 = require("../App");
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
//
|
|
8
|
+
function Inject(serviceName) {
|
|
9
|
+
return (target, propertyKey, parameterIndex) => {
|
|
10
|
+
const existingInjectedParameters = Reflect.getMetadata("inject_params", target) || [];
|
|
11
|
+
// Add the new injection metadata (index ensures correct parameter order)
|
|
12
|
+
existingInjectedParameters[parameterIndex] = { serviceName };
|
|
13
|
+
// Define the metadata again, ensuring the parameters are in correct order
|
|
14
|
+
Reflect.defineMetadata("inject_params", existingInjectedParameters, target);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function Injectable(singleton = false) {
|
|
18
|
+
const container = App_1.app.container;
|
|
19
|
+
return function (target) {
|
|
20
|
+
singleton
|
|
21
|
+
? container.singleton(target.name, () => new target())
|
|
22
|
+
: container.bind(target.name, () => new target());
|
|
23
|
+
};
|
|
24
|
+
}
|
package/lib/Error/AppError.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare class AppError extends Error {
|
|
2
2
|
message: string;
|
|
3
3
|
type?: string;
|
|
4
|
-
|
|
5
|
-
constructor(message: string | any, type?: string
|
|
4
|
+
error_action: string;
|
|
5
|
+
constructor(message: string | any, type?: string);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=AppError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppError.d.ts","sourceRoot":"","sources":["../../../framework/lib/Error/AppError.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"AppError.d.ts","sourceRoot":"","sources":["../../../framework/lib/Error/AppError.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAe;gBAC9B,OAAO,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM;CAKjD"}
|
package/lib/Error/AppError.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppError = void 0;
|
|
4
4
|
class AppError extends Error {
|
|
5
|
-
constructor(message, type
|
|
5
|
+
constructor(message, type) {
|
|
6
6
|
super(message);
|
|
7
|
+
this.error_action = "app_error";
|
|
7
8
|
this.message = message;
|
|
8
9
|
this.type = type;
|
|
9
|
-
this.errorFile = errorFile;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
exports.AppError = AppError;
|
|
@@ -2,8 +2,14 @@ import { Application } from "express";
|
|
|
2
2
|
export declare class AppErrorHandler {
|
|
3
3
|
private app;
|
|
4
4
|
constructor(app: Application);
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a given string represents a valid path.
|
|
7
|
+
* @param pathString The string to check.
|
|
8
|
+
* @returns {boolean} True if it is a valid path; otherwise, false.
|
|
9
|
+
*/
|
|
10
|
+
isPath(str: string): boolean;
|
|
5
11
|
errorRoutesHandler(): Application;
|
|
6
|
-
|
|
12
|
+
private extractErrorPath;
|
|
7
13
|
handler(app: any): void;
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=AppErrorHandler.d.ts.map
|
|
@@ -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;AAMtC,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;IA0BxB,OAAO,CAAC,GAAG,EAAE,GAAG;CAoCjB"}
|
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.AppErrorHandler = void 0;
|
|
4
7
|
const error_1 = require("./Constants/error");
|
|
5
8
|
const DisplayErrorCode_1 = require("./DisplayErrorCode");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
6
10
|
class AppErrorHandler {
|
|
7
11
|
constructor(app) {
|
|
8
12
|
this.app = app;
|
|
9
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a given string represents a valid path.
|
|
16
|
+
* @param pathString The string to check.
|
|
17
|
+
* @returns {boolean} True if it is a valid path; otherwise, false.
|
|
18
|
+
*/
|
|
19
|
+
isPath(str) {
|
|
20
|
+
return path_1.default.isAbsolute(str) || path_1.default.extname(str) !== "";
|
|
21
|
+
}
|
|
10
22
|
errorRoutesHandler() {
|
|
11
23
|
return this.app.all("*", (req, res) => {
|
|
12
24
|
return res.sendFile(__dirname + "/public/pageNotFound.html");
|
|
13
25
|
});
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
extractErrorPath(stackArray, isDatabaseError = false, index = 1) {
|
|
28
|
+
if (!isDatabaseError) {
|
|
29
|
+
const lastError = stackArray[stackArray.length - 1];
|
|
30
|
+
const parts = lastError.split(/\s/g);
|
|
31
|
+
return parts[parts.length - 1];
|
|
32
|
+
}
|
|
33
|
+
const currentError = stackArray[index];
|
|
34
|
+
const parts = currentError.split(/\s/g);
|
|
35
|
+
const errorPath = parts[parts.length - 1];
|
|
36
|
+
console.log(errorPath);
|
|
37
|
+
if (index >= 5) {
|
|
38
|
+
return "Internal server error";
|
|
39
|
+
}
|
|
40
|
+
if (!this.isPath(errorPath)) {
|
|
41
|
+
return this.extractErrorPath(stackArray, true, index + 1);
|
|
42
|
+
}
|
|
43
|
+
return errorPath;
|
|
19
44
|
}
|
|
20
45
|
handler(app) {
|
|
21
46
|
app.use((err, req, res, next) => {
|
|
@@ -29,15 +54,21 @@ class AppErrorHandler {
|
|
|
29
54
|
if (err.type === error_1.API_VALIDATION_ERROR) {
|
|
30
55
|
return res.json({ message: err.message }).status(400);
|
|
31
56
|
}
|
|
32
|
-
if (err.
|
|
57
|
+
if (err.error_action === "database") {
|
|
33
58
|
const errArray = err.stack?.split(/\n/g) || [];
|
|
34
|
-
const errorPath = this.
|
|
59
|
+
const errorPath = this.extractErrorPath(errArray);
|
|
35
60
|
return DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res);
|
|
36
61
|
}
|
|
62
|
+
// if (err.error_action === "app_error") {
|
|
63
|
+
const errArray = err.stack?.split(/\n/g) || [];
|
|
64
|
+
const errorPath = this.extractErrorPath(errArray, true);
|
|
65
|
+
return DisplayErrorCode_1.DisplayError.show(errorPath, err.message, res);
|
|
66
|
+
// }
|
|
37
67
|
return res
|
|
38
68
|
.json({
|
|
39
69
|
message: err.message,
|
|
40
70
|
stack: err.stack,
|
|
71
|
+
// type: err.type,
|
|
41
72
|
})
|
|
42
73
|
.status(statusCode || 500);
|
|
43
74
|
});
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DisplayError extends
|
|
1
|
+
import { ErrorHighLighter } from "./ErrorHightLight";
|
|
2
|
+
export declare class DisplayError extends ErrorHighLighter {
|
|
3
|
+
/**
|
|
4
|
+
* Displays the error in the response.
|
|
5
|
+
* @param errorPath The path to the error file, including line numbers.
|
|
6
|
+
* @param message The error message to display.
|
|
7
|
+
* @param res The Express response object.
|
|
8
|
+
* @returns The response after sending the error HTML.
|
|
9
|
+
*/
|
|
3
10
|
static show(errorPath: string, message: any, res: any): any;
|
|
4
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Renders the error HTML response.
|
|
13
|
+
* @param res The Express response object.
|
|
14
|
+
* @param code The formatted code to include in the HTML.
|
|
15
|
+
* @param line The line number to highlight.
|
|
16
|
+
* @param message The error message to display.
|
|
17
|
+
* @returns The HTML response.
|
|
18
|
+
*/
|
|
19
|
+
static renderHtml(res: any, code: string, line: any, message: any): any;
|
|
5
20
|
}
|
|
6
21
|
//# sourceMappingURL=DisplayErrorCode.d.ts.map
|