@ccci/micro-server 1.0.96 → 1.0.97
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
CHANGED
|
@@ -119109,7 +119109,7 @@ class Mailer {
|
|
|
119109
119109
|
import fs6 from "node:fs";
|
|
119110
119110
|
import path3 from "node:path";
|
|
119111
119111
|
class WebSocketServer {
|
|
119112
|
-
|
|
119112
|
+
static init(port = 5001, dir, folder = "sockets") {
|
|
119113
119113
|
let handlers = [];
|
|
119114
119114
|
let fullDir = path3.join(dir, folder);
|
|
119115
119115
|
fs6.readdirSync(fullDir).forEach((file) => {
|
|
@@ -119158,12 +119158,14 @@ class WebSocketServer {
|
|
|
119158
119158
|
}
|
|
119159
119159
|
});
|
|
119160
119160
|
Logger.info(`Web Socket Sever ready at: http://127.0.0.1:${port}\n`);
|
|
119161
|
+
return handlers;
|
|
119161
119162
|
}
|
|
119162
119163
|
}
|
|
119163
119164
|
|
|
119164
119165
|
// src/utils/ApplicationServer.ts
|
|
119165
119166
|
class ApplicationServer {
|
|
119166
119167
|
static app;
|
|
119168
|
+
static socketHandlers;
|
|
119167
119169
|
static async bootstrap(port, options, sync) {
|
|
119168
119170
|
ApplicationServer.app = import_express.default();
|
|
119169
119171
|
ApplicationServer.app.use(import_cors.default());
|
|
@@ -119180,7 +119182,7 @@ class ApplicationServer {
|
|
|
119180
119182
|
const server = ApplicationServer.app.listen(port, async () => {
|
|
119181
119183
|
Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
|
|
119182
119184
|
if (options?.enableWebSocket) {
|
|
119183
|
-
|
|
119185
|
+
WebSocketServer.init(options?.websocketPort, process.cwd(), options?.websocketDir);
|
|
119184
119186
|
}
|
|
119185
119187
|
if (options?.enableMinio) {
|
|
119186
119188
|
await Uploader.init(options);
|
|
@@ -119200,9 +119202,12 @@ class ApplicationServer {
|
|
|
119200
119202
|
}
|
|
119201
119203
|
});
|
|
119202
119204
|
}
|
|
119203
|
-
getInstance() {
|
|
119205
|
+
static getInstance() {
|
|
119204
119206
|
return ApplicationServer.app;
|
|
119205
119207
|
}
|
|
119208
|
+
static getWebsocketHandlers() {
|
|
119209
|
+
return ApplicationServer.socketHandlers;
|
|
119210
|
+
}
|
|
119206
119211
|
}
|
|
119207
119212
|
// src/utils/BaseRouter.ts
|
|
119208
119213
|
var import_express2 = __toESM(require_express2(), 1);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Application } from 'express';
|
|
2
2
|
import { ApplicationOptionType } from '@/types/ApplicationOptionType';
|
|
3
3
|
/**
|
|
4
4
|
* Application Sever class
|
|
5
5
|
*/
|
|
6
6
|
export default class ApplicationServer {
|
|
7
7
|
static app: Application;
|
|
8
|
+
static socketHandlers: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
handler: any;
|
|
11
|
+
}>;
|
|
8
12
|
/**
|
|
9
13
|
* Initializes the application server
|
|
10
14
|
* @param {number} port port for the micro service
|
|
@@ -13,6 +17,10 @@ export default class ApplicationServer {
|
|
|
13
17
|
*
|
|
14
18
|
*/
|
|
15
19
|
static bootstrap(port: number, options?: ApplicationOptionType, sync?: Array<string> | Boolean): Promise<void>;
|
|
16
|
-
getInstance():
|
|
20
|
+
static getInstance(): Application;
|
|
21
|
+
static getWebsocketHandlers(): Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
handler: any;
|
|
24
|
+
}>;
|
|
17
25
|
}
|
|
18
26
|
//# sourceMappingURL=ApplicationServer.d.ts.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export default class WebSocketServer {
|
|
2
|
-
|
|
2
|
+
static init(port: number | undefined, dir: string, folder?: string): Array<{
|
|
3
|
+
path: string;
|
|
4
|
+
handler: any;
|
|
5
|
+
}>;
|
|
3
6
|
}
|
|
4
7
|
//# sourceMappingURL=WebSocketServer.d.ts.map
|