badmfck-api-server 1.9.3 → 1.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- import { Response } from 'express';
1
+ import { Application, Response } from 'express';
2
2
  import { BaseService, IBaseService } from './BaseService';
3
3
  import { IBaseEndpoint } from './BaseEndpoint';
4
4
  import { HTTPRequestVO, TransferPacketVO } from './structures/Interfaces';
@@ -39,6 +39,7 @@ export declare function getDefaultOptions(): APIServiceOptions;
39
39
  export declare const REQ_CREATE_NET_LOG: Req<void, APIServiceNetworkLogItem>;
40
40
  export declare const REQ_HTTP_LOG: Req<void, APIServiceNetworkLogItem[]>;
41
41
  export declare const REQ_HTTP_REQUESTS_COUNT: Req<void, number>;
42
+ export declare const REQ_HTTP_SERVER: Req<void, Application>;
42
43
  export declare function Initializer(services: IBaseService[]): Promise<void>;
43
44
  export declare class APIService extends BaseService {
44
45
  private static nextLogID;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.APIService = exports.Initializer = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.REQ_CREATE_NET_LOG = exports.getDefaultOptions = void 0;
6
+ exports.APIService = exports.Initializer = exports.REQ_HTTP_SERVER = exports.REQ_HTTP_REQUESTS_COUNT = exports.REQ_HTTP_LOG = exports.REQ_CREATE_NET_LOG = exports.getDefaultOptions = void 0;
7
7
  const express_1 = __importDefault(require("express"));
8
8
  const BaseService_1 = require("./BaseService");
9
9
  const cors_1 = __importDefault(require("cors"));
@@ -43,6 +43,7 @@ exports.getDefaultOptions = getDefaultOptions;
43
43
  exports.REQ_CREATE_NET_LOG = new badmfck_signal_1.Req(undefined, "REQ_CREATE_NET_LOG");
44
44
  exports.REQ_HTTP_LOG = new badmfck_signal_1.Req(undefined, "REQ_HTTP_LOG");
45
45
  exports.REQ_HTTP_REQUESTS_COUNT = new badmfck_signal_1.Req(undefined, "REQ_HTTP_REQUESTS_COUNT");
46
+ exports.REQ_HTTP_SERVER = new badmfck_signal_1.Req(undefined, "REQ_HTTP_SERVER");
46
47
  const activeServices = [];
47
48
  const entryPoints = [];
48
49
  async function Initializer(services) {
@@ -102,6 +103,7 @@ class APIService extends BaseService_1.BaseService {
102
103
  return log;
103
104
  };
104
105
  const app = (0, express_1.default)();
106
+ exports.REQ_HTTP_SERVER.listener = async (ignore) => app;
105
107
  if (this.options.isProductionEnvironment)
106
108
  app.set("env", 'production');
107
109
  app.use(express_1.default.json({ limit: '10mb' }));
@@ -1,5 +1,8 @@
1
1
  import { BaseService } from "./BaseService";
2
+ export interface IWebSocketServiceOptions {
3
+ }
2
4
  export declare class WebsocketService extends BaseService {
3
- constructor();
5
+ options: IWebSocketServiceOptions;
6
+ constructor(opt?: IWebSocketServiceOptions);
4
7
  init(): Promise<void>;
5
8
  }
@@ -2,9 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebsocketService = void 0;
4
4
  const BaseService_1 = require("./BaseService");
5
+ const getDefaultWebSocketServiceOptions = () => {
6
+ return {};
7
+ };
5
8
  class WebsocketService extends BaseService_1.BaseService {
6
- constructor() {
9
+ options;
10
+ constructor(opt) {
7
11
  super("WebsocketService");
12
+ this.options = { ...getDefaultWebSocketServiceOptions(), opt };
8
13
  }
9
14
  async init() {
10
15
  super.init();
@@ -15,7 +15,7 @@ class UID {
15
15
  + Math.round(Math.random() * 1000)).toString(16), 'hex').toString('base64');
16
16
  uid = uid.replaceAll("=", "");
17
17
  uid = uid.replaceAll("+", ".");
18
- uid = uid.replaceAll("/", "-");
18
+ uid = uid.replaceAll("/", "_");
19
19
  return uid;
20
20
  }
21
21
  static generateRandomNumberBase(count) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "express": "^4.19.2",
27
27
  "express-fileupload": "^1.5.0",
28
28
  "mysql": "^2.18.1",
29
- "ws": "^8.17.0"
29
+ "ws": "^8.18.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/cors": "^2.8.13",