badmfck-api-server 2.0.9 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  import { Application, Response } from 'express';
3
3
  import { BaseService, IBaseService } from './BaseService';
4
4
  import { IBaseEndpoint } from './BaseEndpoint';
5
- import { HTTPRequestVO, TransferPacketVO } from './structures/Interfaces';
5
+ import { HTTPRequestVO, IError, TransferPacketVO } from './structures/Interfaces';
6
6
  import { Req } from "badmfck-signal";
7
7
  import http from 'http';
8
8
  export interface APIServiceNetworkLogItem {
@@ -45,7 +45,7 @@ export declare const REQ_HTTP_SERVER: Req<void, {
45
45
  express: Application;
46
46
  http: http.Server;
47
47
  }>;
48
- export declare const REQ_INTERNAL_CALL: Req<HTTPRequestVO, TransferPacketVO>;
48
+ export declare const REQ_INTERNAL_CALL: Req<HTTPRequestVO, IError | any>;
49
49
  export declare function Initializer(services: IBaseService[]): Promise<void>;
50
50
  export declare class APIService extends BaseService {
51
51
  private static nextLogID;
@@ -83,7 +83,7 @@ async function Initializer(services) {
83
83
  exports.Initializer = Initializer;
84
84
  class APIService extends BaseService_1.BaseService {
85
85
  static nextLogID = 0;
86
- version = "2.0.9";
86
+ version = "2.1.1";
87
87
  options;
88
88
  monitor;
89
89
  monitorIndexFile;
@@ -133,8 +133,13 @@ class APIService extends BaseService_1.BaseService {
133
133
  if (!i || !i.endpoints)
134
134
  continue;
135
135
  for (let j of i.endpoints) {
136
- if (j.endpoint === req.endpoint) {
137
- return await i.execute(req);
136
+ let ep = BaseEndpoint_1.BaseEndpoint.getEntryPoint() + j.endpoint;
137
+ ep = ep.replaceAll("//", "/");
138
+ if (ep === req.endpoint) {
139
+ const response = await i.execute(req);
140
+ if (response.error)
141
+ return response.error;
142
+ return response.data;
138
143
  }
139
144
  }
140
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "2.0.9",
3
+ "version": "2.1.1",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",