@ccci/micro-server 1.0.17 → 1.0.18
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/index.js +7 -5
- package/dist/utils/WebsocketServer.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -86884,7 +86884,7 @@ var require_winston = __commonJS((exports) => {
|
|
|
86884
86884
|
// src/utils/ApplicationServer.ts
|
|
86885
86885
|
var import_express = __toESM(require_express2(), 1);
|
|
86886
86886
|
var import_cors = __toESM(require_lib3(), 1);
|
|
86887
|
-
import
|
|
86887
|
+
import path3 from "path";
|
|
86888
86888
|
|
|
86889
86889
|
// node_modules/helmet/index.mjs
|
|
86890
86890
|
var normalizeDirectives = function(options) {
|
|
@@ -87651,12 +87651,14 @@ class RouterFactory {
|
|
|
87651
87651
|
|
|
87652
87652
|
// src/utils/WebSocketServer.ts
|
|
87653
87653
|
import fs3 from "node:fs";
|
|
87654
|
+
import path2 from "node:path";
|
|
87654
87655
|
class WebSocketServer {
|
|
87655
|
-
constructor(port = 3001,
|
|
87656
|
+
constructor(port = 3001, dir = "sockets") {
|
|
87656
87657
|
let handlers = [];
|
|
87657
|
-
fs3.readdirSync(
|
|
87658
|
+
fs3.readdirSync(dir).forEach((file) => {
|
|
87658
87659
|
if (file.toLowerCase().indexOf(".ts")) {
|
|
87659
|
-
|
|
87660
|
+
let filePath = path2.join(dir, file);
|
|
87661
|
+
import(filePath).then((handlerClass) => {
|
|
87660
87662
|
let path3 = file.replace(".ts", "");
|
|
87661
87663
|
let handler = new handlerClass.default;
|
|
87662
87664
|
handlers.push({ path: path3, handler });
|
|
@@ -87718,7 +87720,7 @@ class ApplicationServer {
|
|
|
87718
87720
|
await db.connect(conn[0]);
|
|
87719
87721
|
await db.initializeModels();
|
|
87720
87722
|
ApplicationServer.app.get("/", (req, resp) => {
|
|
87721
|
-
return resp.sendFile(
|
|
87723
|
+
return resp.sendFile(path3.resolve("index.html"));
|
|
87722
87724
|
});
|
|
87723
87725
|
Logger.info("Create API Routes...\n");
|
|
87724
87726
|
new RouterFactory(ApplicationServer.app, process.cwd(), "routes");
|