@ccci/micro-server 1.0.11 → 1.0.13
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 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -98456,7 +98456,7 @@ var require_dist4 = __commonJS((exports, module) => {
|
|
|
98456
98456
|
// src/utils/ApplicationServer.ts
|
|
98457
98457
|
var import_express = __toESM(require_express2(), 1);
|
|
98458
98458
|
var import_cors = __toESM(require_lib3(), 1);
|
|
98459
|
-
import
|
|
98459
|
+
import path2 from "path";
|
|
98460
98460
|
|
|
98461
98461
|
// node_modules/helmet/index.mjs
|
|
98462
98462
|
var normalizeDirectives = function(options) {
|
|
@@ -99226,26 +99226,13 @@ var dist = __toESM(require_dist4(), 1);
|
|
|
99226
99226
|
var { Server, Namespace, Socket } = dist.default;
|
|
99227
99227
|
|
|
99228
99228
|
// src/utils/WebsocketServer.ts
|
|
99229
|
-
import fs3 from "fs";
|
|
99230
|
-
import path2 from "path";
|
|
99231
|
-
|
|
99232
99229
|
class WebSocketServer {
|
|
99233
99230
|
static io;
|
|
99234
99231
|
constructor(app, folderName = "sockets") {
|
|
99235
99232
|
WebSocketServer.io = new Server(app);
|
|
99236
99233
|
WebSocketServer.io.on("connection", (socket) => {
|
|
99237
|
-
|
|
99238
|
-
|
|
99239
|
-
let fullName = path2.join(folderName, file);
|
|
99240
|
-
if (file.toLowerCase().indexOf(".js") || file.toLowerCase().indexOf(".ts")) {
|
|
99241
|
-
let socketName = file.replace(".js", "").replace(".ts", "").split("\\").join("/");
|
|
99242
|
-
console.log("socketClass :>> ", fullName);
|
|
99243
|
-
import(fullName).then((socketClass) => {
|
|
99244
|
-
let instance = new socketClass.default(socket);
|
|
99245
|
-
console.log("socketInstance :>> ", instance);
|
|
99246
|
-
});
|
|
99247
|
-
}
|
|
99248
|
-
});
|
|
99234
|
+
Logger.info(`connected :>> ${JSON.stringify(socket)}`);
|
|
99235
|
+
socket.emit("connected...");
|
|
99249
99236
|
});
|
|
99250
99237
|
}
|
|
99251
99238
|
}
|
|
@@ -99266,7 +99253,7 @@ class ApplicationServer {
|
|
|
99266
99253
|
await db.connect(conn[0]);
|
|
99267
99254
|
await db.initializeModels();
|
|
99268
99255
|
ApplicationServer.app.get("/", (req, resp) => {
|
|
99269
|
-
return resp.sendFile(
|
|
99256
|
+
return resp.sendFile(path2.resolve("index.html"));
|
|
99270
99257
|
});
|
|
99271
99258
|
Logger.info("Create API Routes...\n");
|
|
99272
99259
|
new RouterFactory(ApplicationServer.app, process.cwd(), "routes");
|
|
@@ -99275,7 +99262,9 @@ class ApplicationServer {
|
|
|
99275
99262
|
Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
|
|
99276
99263
|
});
|
|
99277
99264
|
if (options?.enableWebSocket) {
|
|
99278
|
-
|
|
99265
|
+
Logger.info("enabling websocket :>>");
|
|
99266
|
+
let weboscket = new WebSocketServer(server);
|
|
99267
|
+
Logger.info(`enabling websocket :>> ${JSON.stringify(weboscket)}}`);
|
|
99279
99268
|
}
|
|
99280
99269
|
}
|
|
99281
99270
|
getInstance() {
|