@ccci/micro-server 1.0.16 → 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.d.ts CHANGED
@@ -8,5 +8,7 @@ export { ConstructQuery, ResponseHelper, ErrorResponseHandler, } from './utils/B
8
8
  export { default as IBaseModel } from './utils/IBaseModel';
9
9
  export { default as BaseModel } from './utils/BaseModel';
10
10
  export { default as DatabaseConnector } from './utils/DatabaseConnector';
11
+ export { default as BaseSocketHandler } from './utils/BaseSocketHandler';
12
+ export type { WebSocketData } from './types/BaseSocketType';
11
13
  export { PublicAccess, PrivateAccess, endpoint } from './decorators/Endpoints';
12
14
  //# sourceMappingURL=index.d.ts.map
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 path2 from "path";
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, path2 = "sockets") {
87656
+ constructor(port = 3001, dir = "sockets") {
87656
87657
  let handlers = [];
87657
- fs3.readdirSync(path2).forEach((file) => {
87658
+ fs3.readdirSync(dir).forEach((file) => {
87658
87659
  if (file.toLowerCase().indexOf(".ts")) {
87659
- import(`./${path2}/${file}`).then((handlerClass) => {
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(path2.resolve("index.html"));
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");
@@ -88220,6 +88222,23 @@ class BaseModel extends Model {
88220
88222
  });
88221
88223
  }
88222
88224
  }
88225
+ // src/utils/BaseSocketHandler.ts
88226
+ class BaseSocketHandler {
88227
+ async upgrade(req, server) {
88228
+ if (server.upgrade(req, { data: { channel: "default" } })) {
88229
+ return;
88230
+ }
88231
+ }
88232
+ async accept(ws, message) {
88233
+ throw new Error("accept(ws:ServerWebSocket, message:string) - not yet implemented!");
88234
+ }
88235
+ async connect(ws) {
88236
+ throw new Error("connect(ws:ServerWebSocket) - not yet implemented!");
88237
+ }
88238
+ async disconnect(ws, code, reason) {
88239
+ throw new Error("disconnect(ws:ServerWebSocket, code:number, reason: string) - not yet implemented!");
88240
+ }
88241
+ }
88223
88242
  // src/decorators/Endpoints.ts
88224
88243
  var endpoint = (target, methodName, descriptor) => {
88225
88244
  };
@@ -88242,6 +88261,7 @@ export {
88242
88261
  ErrorResponseHandler,
88243
88262
  DatabaseConnector,
88244
88263
  ConstructQuery,
88264
+ BaseSocketHandler,
88245
88265
  BaseRouter,
88246
88266
  BaseModel,
88247
88267
  BaseController,
@@ -1,4 +1,4 @@
1
1
  export default class WebSocketServer {
2
- constructor(port?: number, path?: string);
2
+ constructor(port?: number, dir?: string);
3
3
  }
4
4
  //# sourceMappingURL=WebSocketServer.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",