badmfck-api-server 1.4.6 → 1.4.8

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.
@@ -31,6 +31,13 @@ class BaseEndpoint {
31
31
  }
32
32
  registerEndpoints(endpoints) {
33
33
  for (let i of endpoints) {
34
+ if (i.endpoint === "" || i.endpoint === "/") {
35
+ let empty = i.endpoint === "";
36
+ i.endpoint = this.endpoint;
37
+ if (i.endpoint.endsWith("/") && empty)
38
+ i.endpoint = i.endpoint.substring(0, i.endpoint.length - 1);
39
+ continue;
40
+ }
34
41
  if (i.endpoint.startsWith("/"))
35
42
  i.endpoint = i.endpoint.substring(1);
36
43
  if (i.endpoint.endsWith("/"))
@@ -186,19 +186,15 @@ class LogService extends BaseService_1.BaseService {
186
186
  return "undefined";
187
187
  let res = "";
188
188
  if (typeof data === "object") {
189
- if ("toString" in data && data.toString && typeof data.toString === "function") {
190
- res = data.toString();
189
+ try {
190
+ const tmp = JSON.stringify(data, null, "\t");
191
+ res = tmp ?? "";
191
192
  }
192
- else {
193
- try {
194
- const tmp = JSON.stringify(data, null, "\t");
195
- res = tmp ?? "";
196
- }
197
- catch (e) {
198
- res = `${data}`;
199
- }
193
+ catch (e) {
194
+ if ("toString" in data && data.toString && typeof data.toString === "function")
195
+ res = data.toString();
200
196
  }
201
- if (res === "[object Map]" && "size" in data) {
197
+ if (`${data}` === "[object Map]" && "size" in data) {
202
198
  try {
203
199
  const arr = [];
204
200
  for (let i of data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",