badmfck-api-server 1.4.8 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ async function Initializer(services) {
43
43
  exports.Initializer = Initializer;
44
44
  class APIService extends BaseService_1.BaseService {
45
45
  static nextLogID = 0;
46
- version = "1.4.6";
46
+ version = "1.5.0";
47
47
  options;
48
48
  netLog = [];
49
49
  constructor(options) {
@@ -151,6 +151,7 @@ class APIService extends BaseService_1.BaseService {
151
151
  result = await i.execute(httpRequest);
152
152
  }
153
153
  catch (e) {
154
+ console.error(e);
154
155
  if (this.options.onError)
155
156
  this.options.onError(e);
156
157
  this.sendResponse(res, {
@@ -158,6 +159,7 @@ class APIService extends BaseService_1.BaseService {
158
159
  error: {
159
160
  code: 10002,
160
161
  message: "Internal server error",
162
+ details: `${e}`
161
163
  }
162
164
  }, tme, ep, log);
163
165
  return;
@@ -60,7 +60,7 @@ class BaseEndpoint {
60
60
  if (this.endpoints && this.endpoints.length > 0) {
61
61
  for (let i of this.endpoints) {
62
62
  if (BaseEndpoint.entrypoint + i.endpoint === req.endpoint && i.handler && typeof i.handler === "function")
63
- return i.handler(req);
63
+ return i.handler.call(this, req);
64
64
  }
65
65
  }
66
66
  (0, LogService_1.logWarn)("${BaseEndpoint.js}", "Unhandled entrypoint: " + this.endpoint);
@@ -0,0 +1,5 @@
1
+ import { BaseService } from "./BaseService";
2
+ export declare class WebsocketService extends BaseService {
3
+ constructor();
4
+ init(): Promise<void>;
5
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WebsocketService = void 0;
4
+ const BaseService_1 = require("./BaseService");
5
+ class WebsocketService extends BaseService_1.BaseService {
6
+ constructor() {
7
+ super("WebsocketService");
8
+ }
9
+ async init() {
10
+ super.init();
11
+ }
12
+ }
13
+ exports.WebsocketService = WebsocketService;
@@ -27,4 +27,5 @@ export interface IError {
27
27
  message: string;
28
28
  details?: string;
29
29
  httpStatus?: number;
30
+ stack?: IError[];
30
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.4.8",
3
+ "version": "1.5.0",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,11 +19,13 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@types/mysql": "^2.15.21",
22
+ "@types/ws": "^8.5.9",
22
23
  "axios": "^1.4.0",
23
24
  "badmfck-signal": "^1.2.7",
24
25
  "cors": "^2.8.5",
25
26
  "express": "^4.18.2",
26
- "mysql": "^2.18.1"
27
+ "mysql": "^2.18.1",
28
+ "ws": "^8.14.2"
27
29
  },
28
30
  "devDependencies": {
29
31
  "@types/cors": "^2.8.13",