jcc-express-mvc 1.6.1 → 1.6.2
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/lib/Application/Application.js +58 -52
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
exports.Application = void 0;
|
|
7
9
|
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
@@ -14,57 +16,61 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
14
16
|
const Config_1 = require("../Config/Config");
|
|
15
17
|
const rootPath = app_root_path_1.default.path;
|
|
16
18
|
class Application extends ExpressApplication_1.ExpressApplication {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.booted = false;
|
|
22
|
+
this.providers = [];
|
|
23
|
+
this.rootPath = rootPath;
|
|
24
|
+
this.configRoutes = [];
|
|
25
|
+
this.VERSION = "0.0.0";
|
|
26
|
+
dotenv_1.default.config({ path: `${rootPath}/.env` });
|
|
27
|
+
this.instance("app", this);
|
|
28
|
+
this.singleton(
|
|
29
|
+
"RouteServiceProvider",
|
|
30
|
+
RouteServiceProvider_1.RouteServiceProvider
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
// Register a service provider
|
|
34
|
+
registerProviders(Provider) {
|
|
35
|
+
const provider = new Provider(this);
|
|
36
|
+
provider.register();
|
|
37
|
+
this.providers.push(provider);
|
|
38
|
+
if (this.booted) {
|
|
39
|
+
this.bootProvider(provider);
|
|
27
40
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
return this;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
// Boot all registered service providers
|
|
44
|
+
boot() {
|
|
45
|
+
if (!this.booted) {
|
|
46
|
+
this.providers.forEach((provider) => this.bootProvider(provider));
|
|
47
|
+
this.booted = true;
|
|
37
48
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return this.VERSION;
|
|
52
|
-
}
|
|
53
|
-
// Start the application
|
|
54
|
-
async run() {
|
|
55
|
-
if (!this.booted) {
|
|
56
|
-
this.boot();
|
|
57
|
-
}
|
|
58
|
-
const routeServiceProvider = this.resolve("RouteServiceProvider");
|
|
59
|
-
//
|
|
60
|
-
RouteBuilder_1.RouteBuilder.setServiceContainer(this);
|
|
61
|
-
await routeServiceProvider.loadRoutes(this.configRoutes);
|
|
62
|
-
console.log(RouteBuilder_1.RouteBuilder.routeList);
|
|
63
|
-
const server = new Server_1.Server(this);
|
|
64
|
-
server.server(Number(Config_1.config.get("PORT", "5500")));
|
|
65
|
-
}
|
|
66
|
-
static configuration() {
|
|
67
|
-
return new ApplicationBuilder_1.ApplicationBuilder(new Application()).withConsole();
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
// Boot a specific provider
|
|
52
|
+
bootProvider(provider) {
|
|
53
|
+
provider.boot();
|
|
54
|
+
}
|
|
55
|
+
version() {
|
|
56
|
+
return this.VERSION;
|
|
57
|
+
}
|
|
58
|
+
// Start the application
|
|
59
|
+
async run() {
|
|
60
|
+
if (!this.booted) {
|
|
61
|
+
this.boot();
|
|
68
62
|
}
|
|
63
|
+
const routeServiceProvider = this.resolve("RouteServiceProvider");
|
|
64
|
+
//
|
|
65
|
+
RouteBuilder_1.RouteBuilder.setServiceContainer(this);
|
|
66
|
+
await routeServiceProvider.loadRoutes(this.configRoutes);
|
|
67
|
+
const server = new Server_1.Server(this);
|
|
68
|
+
server.server(Number(Config_1.config.get("PORT", "5500")));
|
|
69
|
+
}
|
|
70
|
+
static configuration() {
|
|
71
|
+
return new ApplicationBuilder_1.ApplicationBuilder(
|
|
72
|
+
new Application()
|
|
73
|
+
).withConsole();
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
exports.Application = Application;
|