@ccci/micro-server 1.0.96 → 1.0.98
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.d.ts +1 -0
- package/dist/index.js +20 -3
- package/dist/utils/ApplicationServer.d.ts +11 -2
- package/dist/utils/WebsocketServer.d.ts +14 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { default as BaseModel } from './utils/BaseModel';
|
|
|
10
10
|
export { default as ErrorHandler } from './utils/ErrorHandler';
|
|
11
11
|
export { generate, verify, decode } from './utils/TokenGenerator';
|
|
12
12
|
export { default as DatabaseConnector } from './utils/DatabaseConnector';
|
|
13
|
+
export { default as WebSocketServer } from './utils/WebSocketServer';
|
|
13
14
|
export { default as BaseSocketHandler } from './utils/BaseSocketHandler';
|
|
14
15
|
export type { WebSocketData } from './types/BaseSocketType';
|
|
15
16
|
export { PublicAccess, PrivateAccess, endpoint } from './decorators/Endpoints';
|
package/dist/index.js
CHANGED
|
@@ -119109,7 +119109,8 @@ class Mailer {
|
|
|
119109
119109
|
import fs6 from "node:fs";
|
|
119110
119110
|
import path3 from "node:path";
|
|
119111
119111
|
class WebSocketServer {
|
|
119112
|
-
|
|
119112
|
+
static socketHandlers;
|
|
119113
|
+
static init(port = 5001, dir, folder = "sockets") {
|
|
119113
119114
|
let handlers = [];
|
|
119114
119115
|
let fullDir = path3.join(dir, folder);
|
|
119115
119116
|
fs6.readdirSync(fullDir).forEach((file) => {
|
|
@@ -119158,12 +119159,24 @@ class WebSocketServer {
|
|
|
119158
119159
|
}
|
|
119159
119160
|
});
|
|
119160
119161
|
Logger.info(`Web Socket Sever ready at: http://127.0.0.1:${port}\n`);
|
|
119162
|
+
WebSocketServer.socketHandlers = handlers;
|
|
119163
|
+
return handlers;
|
|
119164
|
+
}
|
|
119165
|
+
static getSocketHandlers() {
|
|
119166
|
+
return WebSocketServer.socketHandlers;
|
|
119167
|
+
}
|
|
119168
|
+
static getHandler(path4) {
|
|
119169
|
+
let handler = null;
|
|
119170
|
+
let socket = WebSocketServer.socketHandlers.find((websocket) => websocket.path === path4);
|
|
119171
|
+
handler = socket ? socket.handler : null;
|
|
119172
|
+
return handler;
|
|
119161
119173
|
}
|
|
119162
119174
|
}
|
|
119163
119175
|
|
|
119164
119176
|
// src/utils/ApplicationServer.ts
|
|
119165
119177
|
class ApplicationServer {
|
|
119166
119178
|
static app;
|
|
119179
|
+
static socketHandlers;
|
|
119167
119180
|
static async bootstrap(port, options, sync) {
|
|
119168
119181
|
ApplicationServer.app = import_express.default();
|
|
119169
119182
|
ApplicationServer.app.use(import_cors.default());
|
|
@@ -119180,7 +119193,7 @@ class ApplicationServer {
|
|
|
119180
119193
|
const server = ApplicationServer.app.listen(port, async () => {
|
|
119181
119194
|
Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
|
|
119182
119195
|
if (options?.enableWebSocket) {
|
|
119183
|
-
|
|
119196
|
+
WebSocketServer.init(options?.websocketPort, process.cwd(), options?.websocketDir);
|
|
119184
119197
|
}
|
|
119185
119198
|
if (options?.enableMinio) {
|
|
119186
119199
|
await Uploader.init(options);
|
|
@@ -119200,9 +119213,12 @@ class ApplicationServer {
|
|
|
119200
119213
|
}
|
|
119201
119214
|
});
|
|
119202
119215
|
}
|
|
119203
|
-
getInstance() {
|
|
119216
|
+
static getInstance() {
|
|
119204
119217
|
return ApplicationServer.app;
|
|
119205
119218
|
}
|
|
119219
|
+
static getWebsocketHandlers() {
|
|
119220
|
+
return ApplicationServer.socketHandlers;
|
|
119221
|
+
}
|
|
119206
119222
|
}
|
|
119207
119223
|
// src/utils/BaseRouter.ts
|
|
119208
119224
|
var import_express2 = __toESM(require_express2(), 1);
|
|
@@ -119746,6 +119762,7 @@ export {
|
|
|
119746
119762
|
generate,
|
|
119747
119763
|
endpoint,
|
|
119748
119764
|
decode,
|
|
119765
|
+
WebSocketServer,
|
|
119749
119766
|
RouterFactory,
|
|
119750
119767
|
ResponseHelper,
|
|
119751
119768
|
PublicAccess,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Application } from 'express';
|
|
2
2
|
import { ApplicationOptionType } from '@/types/ApplicationOptionType';
|
|
3
|
+
import BaseSocketHandler from './BaseSocketHandler';
|
|
3
4
|
/**
|
|
4
5
|
* Application Sever class
|
|
5
6
|
*/
|
|
6
7
|
export default class ApplicationServer {
|
|
7
8
|
static app: Application;
|
|
9
|
+
static socketHandlers: Array<{
|
|
10
|
+
path: string;
|
|
11
|
+
handler: BaseSocketHandler;
|
|
12
|
+
}>;
|
|
8
13
|
/**
|
|
9
14
|
* Initializes the application server
|
|
10
15
|
* @param {number} port port for the micro service
|
|
@@ -13,6 +18,10 @@ export default class ApplicationServer {
|
|
|
13
18
|
*
|
|
14
19
|
*/
|
|
15
20
|
static bootstrap(port: number, options?: ApplicationOptionType, sync?: Array<string> | Boolean): Promise<void>;
|
|
16
|
-
getInstance():
|
|
21
|
+
static getInstance(): Application;
|
|
22
|
+
static getWebsocketHandlers(): Array<{
|
|
23
|
+
path: string;
|
|
24
|
+
handler: any;
|
|
25
|
+
}>;
|
|
17
26
|
}
|
|
18
27
|
//# sourceMappingURL=ApplicationServer.d.ts.map
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import BaseSocketHandler from './BaseSocketHandler';
|
|
1
2
|
export default class WebSocketServer {
|
|
2
|
-
|
|
3
|
+
static socketHandlers: Array<{
|
|
4
|
+
path: string;
|
|
5
|
+
handler: BaseSocketHandler;
|
|
6
|
+
}>;
|
|
7
|
+
static init(port: number | undefined, dir: string, folder?: string): Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
handler: BaseSocketHandler;
|
|
10
|
+
}>;
|
|
11
|
+
static getSocketHandlers(): Array<{
|
|
12
|
+
path: string;
|
|
13
|
+
handler: BaseSocketHandler;
|
|
14
|
+
}>;
|
|
15
|
+
static getHandler(path: string): BaseSocketHandler | null;
|
|
3
16
|
}
|
|
4
17
|
//# sourceMappingURL=WebSocketServer.d.ts.map
|