@vercube/core 0.0.2-beta.1 → 0.0.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/dist/Common/App.d.ts +9 -0
- package/dist/Services/HttpServer/HttpServer.d.ts +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.mjs +19 -6
- package/package.json +4 -4
package/dist/Common/App.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class App {
|
|
|
9
9
|
private gPluginsRegistry;
|
|
10
10
|
private gHttpServer;
|
|
11
11
|
private gStaticRequestHandler;
|
|
12
|
+
private gLogger;
|
|
12
13
|
/** Holds the initialization status of the application */
|
|
13
14
|
private fIsInitialized;
|
|
14
15
|
/** Holds the dependency injection container */
|
|
@@ -48,6 +49,14 @@ export declare class App {
|
|
|
48
49
|
*/
|
|
49
50
|
listen(): Promise<void>;
|
|
50
51
|
/**
|
|
52
|
+
* Handles an incoming HTTP request.
|
|
53
|
+
* This method is an adapter for HttpServer.handleRequest method.
|
|
54
|
+
*
|
|
55
|
+
* @param {Request} request - The incoming HTTP request
|
|
56
|
+
* @returns {Promise<Response>} The HTTP response
|
|
57
|
+
*/
|
|
58
|
+
fetch(request: Request): Promise<Response>;
|
|
59
|
+
/**
|
|
51
60
|
* Resolves and initializes the plugins for the application.
|
|
52
61
|
*
|
|
53
62
|
* @private
|
package/dist/index.cjs
CHANGED
|
@@ -857,6 +857,7 @@ var App = class {
|
|
|
857
857
|
gPluginsRegistry;
|
|
858
858
|
gHttpServer;
|
|
859
859
|
gStaticRequestHandler;
|
|
860
|
+
gLogger;
|
|
860
861
|
/** Holds the initialization status of the application */
|
|
861
862
|
fIsInitialized = false;
|
|
862
863
|
/** Holds the dependency injection container */
|
|
@@ -910,9 +911,20 @@ var App = class {
|
|
|
910
911
|
await this.resolvePlugins();
|
|
911
912
|
(0, __vercube_di.initializeContainer)(this.container);
|
|
912
913
|
await this.gHttpServer.listen();
|
|
914
|
+
this.gLogger?.info(`\n${__vercube_logger.colors.green("➜")} App listening on port ${__vercube_logger.colors.bold(this.fConfig.server?.port?.toString() ?? "3000")}`);
|
|
913
915
|
this.fIsInitialized = true;
|
|
914
916
|
}
|
|
915
917
|
/**
|
|
918
|
+
* Handles an incoming HTTP request.
|
|
919
|
+
* This method is an adapter for HttpServer.handleRequest method.
|
|
920
|
+
*
|
|
921
|
+
* @param {Request} request - The incoming HTTP request
|
|
922
|
+
* @returns {Promise<Response>} The HTTP response
|
|
923
|
+
*/
|
|
924
|
+
async fetch(request) {
|
|
925
|
+
return this.gHttpServer.handleRequest(request);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
916
928
|
* Resolves and initializes the plugins for the application.
|
|
917
929
|
*
|
|
918
930
|
* @private
|
|
@@ -925,6 +937,7 @@ var App = class {
|
|
|
925
937
|
(0, import_decorate.default)([(0, __vercube_di.Inject)(PluginsRegistry)], App.prototype, "gPluginsRegistry", void 0);
|
|
926
938
|
(0, import_decorate.default)([(0, __vercube_di.Inject)(HttpServer)], App.prototype, "gHttpServer", void 0);
|
|
927
939
|
(0, import_decorate.default)([(0, __vercube_di.Inject)(StaticRequestHandler)], App.prototype, "gStaticRequestHandler", void 0);
|
|
940
|
+
(0, import_decorate.default)([(0, __vercube_di.InjectOptional)(__vercube_logger.Logger)], App.prototype, "gLogger", void 0);
|
|
928
941
|
|
|
929
942
|
//#endregion
|
|
930
943
|
//#region packages/logger/dist/Providers/index.mjs
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { addRoute, createRouter, findRoute } from "rou3";
|
|
|
4
4
|
import { createReadStream } from "node:fs";
|
|
5
5
|
import { extname, join, normalize } from "node:path";
|
|
6
6
|
import { stat } from "node:fs/promises";
|
|
7
|
-
import { BaseLogger, Logger } from "@vercube/logger";
|
|
7
|
+
import { BaseLogger, Logger, colors } from "@vercube/logger";
|
|
8
8
|
import { loadConfig } from "c12";
|
|
9
9
|
import { defu } from "defu";
|
|
10
10
|
|
|
@@ -827,6 +827,7 @@ var App = class {
|
|
|
827
827
|
gPluginsRegistry;
|
|
828
828
|
gHttpServer;
|
|
829
829
|
gStaticRequestHandler;
|
|
830
|
+
gLogger;
|
|
830
831
|
/** Holds the initialization status of the application */
|
|
831
832
|
fIsInitialized = false;
|
|
832
833
|
/** Holds the dependency injection container */
|
|
@@ -880,9 +881,20 @@ var App = class {
|
|
|
880
881
|
await this.resolvePlugins();
|
|
881
882
|
initializeContainer(this.container);
|
|
882
883
|
await this.gHttpServer.listen();
|
|
884
|
+
this.gLogger?.info(`\n${colors.green("➜")} App listening on port ${colors.bold(this.fConfig.server?.port?.toString() ?? "3000")}`);
|
|
883
885
|
this.fIsInitialized = true;
|
|
884
886
|
}
|
|
885
887
|
/**
|
|
888
|
+
* Handles an incoming HTTP request.
|
|
889
|
+
* This method is an adapter for HttpServer.handleRequest method.
|
|
890
|
+
*
|
|
891
|
+
* @param {Request} request - The incoming HTTP request
|
|
892
|
+
* @returns {Promise<Response>} The HTTP response
|
|
893
|
+
*/
|
|
894
|
+
async fetch(request) {
|
|
895
|
+
return this.gHttpServer.handleRequest(request);
|
|
896
|
+
}
|
|
897
|
+
/**
|
|
886
898
|
* Resolves and initializes the plugins for the application.
|
|
887
899
|
*
|
|
888
900
|
* @private
|
|
@@ -895,6 +907,7 @@ __decorate([Inject(Router)], App.prototype, "gRouter", void 0);
|
|
|
895
907
|
__decorate([Inject(PluginsRegistry)], App.prototype, "gPluginsRegistry", void 0);
|
|
896
908
|
__decorate([Inject(HttpServer)], App.prototype, "gHttpServer", void 0);
|
|
897
909
|
__decorate([Inject(StaticRequestHandler)], App.prototype, "gStaticRequestHandler", void 0);
|
|
910
|
+
__decorate([InjectOptional(Logger)], App.prototype, "gLogger", void 0);
|
|
898
911
|
|
|
899
912
|
//#endregion
|
|
900
913
|
//#region packages/logger/dist/Providers/index.mjs
|
|
@@ -913,7 +926,7 @@ const colorIfAllowed = (colorFn) => {
|
|
|
913
926
|
};
|
|
914
927
|
return wrappedFn;
|
|
915
928
|
};
|
|
916
|
-
const colors = {
|
|
929
|
+
const colors$1 = {
|
|
917
930
|
bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
|
|
918
931
|
green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
|
|
919
932
|
yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
|
|
@@ -922,10 +935,10 @@ const colors = {
|
|
|
922
935
|
cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`)
|
|
923
936
|
};
|
|
924
937
|
const LOG_LEVEL_COLORS = {
|
|
925
|
-
debug: colors.green,
|
|
926
|
-
info: colors.bold,
|
|
927
|
-
warn: colors.yellow,
|
|
928
|
-
error: colors.red
|
|
938
|
+
debug: colors$1.green,
|
|
939
|
+
info: colors$1.bold,
|
|
940
|
+
warn: colors$1.yellow,
|
|
941
|
+
error: colors$1.red
|
|
929
942
|
};
|
|
930
943
|
/**
|
|
931
944
|
* ConsoleProvider class for logging messages to the console.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/core",
|
|
3
|
-
"version": "0.0.2
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Core module for Vercube framework",
|
|
5
5
|
"repository": "@vercube/core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"c12": "3.0.3",
|
|
26
26
|
"defu": "6.1.4",
|
|
27
27
|
"pathe": "2.0.3",
|
|
28
|
-
"rou3": "0.6.
|
|
28
|
+
"rou3": "0.6.1",
|
|
29
29
|
"srvx": "0.4.0",
|
|
30
|
-
"@vercube/di": "0.0.2
|
|
31
|
-
"@vercube/logger": "0.0.2
|
|
30
|
+
"@vercube/di": "0.0.2",
|
|
31
|
+
"@vercube/logger": "0.0.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@vitest/coverage-v8": "^3.1.2",
|