Browse Source

refactor: updates eslint rules

e22m4u 3 weeks ago
parent
commit
bb8f93d618

+ 164 - 72
dist/cjs/index.cjs

@@ -122,8 +122,12 @@ __name(cloneDeep, "cloneDeep");
 
 
 // src/utils/is-promise.js
 // src/utils/is-promise.js
 function isPromise(value) {
 function isPromise(value) {
-  if (!value) return false;
-  if (typeof value !== "object") return false;
+  if (!value) {
+    return false;
+  }
+  if (typeof value !== "object") {
+    return false;
+  }
   return typeof value.then === "function";
   return typeof value.then === "function";
 }
 }
 __name(isPromise, "isPromise");
 __name(isPromise, "isPromise");
@@ -131,17 +135,21 @@ __name(isPromise, "isPromise");
 // src/utils/create-error.js
 // src/utils/create-error.js
 var import_js_format = require("@e22m4u/js-format");
 var import_js_format = require("@e22m4u/js-format");
 function createError(errorCtor, message, ...args) {
 function createError(errorCtor, message, ...args) {
-  if (typeof errorCtor !== "function")
+  if (typeof errorCtor !== "function") {
     throw new import_js_format.Errorf(
     throw new import_js_format.Errorf(
       'The first parameter of "createError" must be a constructor, but %v was given.',
       'The first parameter of "createError" must be a constructor, but %v was given.',
       errorCtor
       errorCtor
     );
     );
-  if (message != null && typeof message !== "string")
+  }
+  if (message != null && typeof message !== "string") {
     throw new import_js_format.Errorf(
     throw new import_js_format.Errorf(
       'The second parameter of "createError" must be a String, but %v was given.',
       'The second parameter of "createError" must be a String, but %v was given.',
       message
       message
     );
     );
-  if (message == null) return new errorCtor();
+  }
+  if (message == null) {
+    return new errorCtor();
+  }
   const interpolatedMessage = (0, import_js_format.format)(message, ...args);
   const interpolatedMessage = (0, import_js_format.format)(message, ...args);
   return new errorCtor(interpolatedMessage);
   return new errorCtor(interpolatedMessage);
 }
 }
@@ -150,11 +158,12 @@ __name(createError, "createError");
 // src/utils/to-camel-case.js
 // src/utils/to-camel-case.js
 var import_js_format2 = require("@e22m4u/js-format");
 var import_js_format2 = require("@e22m4u/js-format");
 function toCamelCase(input) {
 function toCamelCase(input) {
-  if (typeof input !== "string")
+  if (typeof input !== "string") {
     throw new import_js_format2.Errorf(
     throw new import_js_format2.Errorf(
       'The first parameter of "toCamelCase" must be a String, but %v was given.',
       'The first parameter of "toCamelCase" must be a String, but %v was given.',
       input
       input
     );
     );
+  }
   return input.replace(/(^\w|[A-Z]|\b\w)/g, (c) => c.toUpperCase()).replace(/\W+/g, "").replace(/(^\w)/g, (c) => c.toLowerCase());
   return input.replace(/(^\w|[A-Z]|\b\w)/g, (c) => c.toUpperCase()).replace(/\W+/g, "").replace(/(^\w)/g, (c) => c.toLowerCase());
 }
 }
 __name(toCamelCase, "toCamelCase");
 __name(toCamelCase, "toCamelCase");
@@ -184,7 +193,9 @@ __name(createRouteMock, "createRouteMock");
 
 
 // src/utils/is-readable-stream.js
 // src/utils/is-readable-stream.js
 function isReadableStream(value) {
 function isReadableStream(value) {
-  if (!value || typeof value !== "object") return false;
+  if (!value || typeof value !== "object") {
+    return false;
+  }
   return typeof value.pipe === "function";
   return typeof value.pipe === "function";
 }
 }
 __name(isReadableStream, "isReadableStream");
 __name(isReadableStream, "isReadableStream");
@@ -192,18 +203,23 @@ __name(isReadableStream, "isReadableStream");
 // src/utils/parse-content-type.js
 // src/utils/parse-content-type.js
 var import_js_format4 = require("@e22m4u/js-format");
 var import_js_format4 = require("@e22m4u/js-format");
 function parseContentType(input) {
 function parseContentType(input) {
-  if (typeof input !== "string")
+  if (typeof input !== "string") {
     throw new import_js_format4.Errorf(
     throw new import_js_format4.Errorf(
       "The first parameter of `parseContentType` must be a String, but %v was given.",
       "The first parameter of `parseContentType` must be a String, but %v was given.",
       input
       input
     );
     );
+  }
   const res = { mediaType: void 0, charset: void 0, boundary: void 0 };
   const res = { mediaType: void 0, charset: void 0, boundary: void 0 };
   const re = /^\s*([^\s;/]+\/[^\s;/]+)(?:;\s*charset=([^\s;]+))?(?:;\s*boundary=([^\s;]+))?.*$/i;
   const re = /^\s*([^\s;/]+\/[^\s;/]+)(?:;\s*charset=([^\s;]+))?(?:;\s*boundary=([^\s;]+))?.*$/i;
   const matches = re.exec(input);
   const matches = re.exec(input);
   if (matches && matches[1]) {
   if (matches && matches[1]) {
     res.mediaType = matches[1];
     res.mediaType = matches[1];
-    if (matches[2]) res.charset = matches[2];
-    if (matches[3]) res.boundary = matches[3];
+    if (matches[2]) {
+      res.charset = matches[2];
+    }
+    if (matches[3]) {
+      res.boundary = matches[3];
+    }
   }
   }
   return res;
   return res;
 }
 }
@@ -211,7 +227,9 @@ __name(parseContentType, "parseContentType");
 
 
 // src/utils/is-writable-stream.js
 // src/utils/is-writable-stream.js
 function isWritableStream(value) {
 function isWritableStream(value) {
-  if (!value || typeof value !== "object") return false;
+  if (!value || typeof value !== "object") {
+    return false;
+  }
   return typeof value.end === "function";
   return typeof value.end === "function";
 }
 }
 __name(isWritableStream, "isWritableStream");
 __name(isWritableStream, "isWritableStream");
@@ -231,40 +249,44 @@ var CHARACTER_ENCODING_LIST = [
   "latin1"
   "latin1"
 ];
 ];
 function fetchRequestBody(request, bodyBytesLimit = 0) {
 function fetchRequestBody(request, bodyBytesLimit = 0) {
-  if (!(request instanceof import_http.IncomingMessage))
+  if (!(request instanceof import_http.IncomingMessage)) {
     throw new import_js_format5.Errorf(
     throw new import_js_format5.Errorf(
       'The first parameter of "fetchRequestBody" must be an IncomingMessage instance, but %v was given.',
       'The first parameter of "fetchRequestBody" must be an IncomingMessage instance, but %v was given.',
       request
       request
     );
     );
-  if (typeof bodyBytesLimit !== "number")
+  }
+  if (typeof bodyBytesLimit !== "number") {
     throw new import_js_format5.Errorf(
     throw new import_js_format5.Errorf(
       'The parameter "bodyBytesLimit" of "fetchRequestBody" must be a number, but %v was given.',
       'The parameter "bodyBytesLimit" of "fetchRequestBody" must be a number, but %v was given.',
       bodyBytesLimit
       bodyBytesLimit
     );
     );
+  }
   return new Promise((resolve, reject) => {
   return new Promise((resolve, reject) => {
     const contentLength = parseInt(
     const contentLength = parseInt(
       request.headers["content-length"] || "0",
       request.headers["content-length"] || "0",
       10
       10
     );
     );
-    if (bodyBytesLimit && contentLength && contentLength > bodyBytesLimit)
+    if (bodyBytesLimit && contentLength && contentLength > bodyBytesLimit) {
       throw createError(
       throw createError(
         import_http_errors.default.PayloadTooLarge,
         import_http_errors.default.PayloadTooLarge,
         "Request body limit is %s bytes, but %s bytes given.",
         "Request body limit is %s bytes, but %s bytes given.",
         bodyBytesLimit,
         bodyBytesLimit,
         contentLength
         contentLength
       );
       );
+    }
     let encoding = "utf-8";
     let encoding = "utf-8";
     const contentType = request.headers["content-type"] || "";
     const contentType = request.headers["content-type"] || "";
     if (contentType) {
     if (contentType) {
       const parsedContentType = parseContentType(contentType);
       const parsedContentType = parseContentType(contentType);
       if (parsedContentType && parsedContentType.charset) {
       if (parsedContentType && parsedContentType.charset) {
         encoding = parsedContentType.charset.toLowerCase();
         encoding = parsedContentType.charset.toLowerCase();
-        if (!CHARACTER_ENCODING_LIST.includes(encoding))
+        if (!CHARACTER_ENCODING_LIST.includes(encoding)) {
           throw createError(
           throw createError(
             import_http_errors.default.UnsupportedMediaType,
             import_http_errors.default.UnsupportedMediaType,
             "Request encoding %v is not supported.",
             "Request encoding %v is not supported.",
             encoding
             encoding
           );
           );
+        }
       }
       }
     }
     }
     const data = [];
     const data = [];
@@ -313,11 +335,12 @@ __name(fetchRequestBody, "fetchRequestBody");
 // src/utils/parse-cookie-string.js
 // src/utils/parse-cookie-string.js
 var import_js_format6 = require("@e22m4u/js-format");
 var import_js_format6 = require("@e22m4u/js-format");
 function parseCookieString(input) {
 function parseCookieString(input) {
-  if (typeof input !== "string")
+  if (typeof input !== "string") {
     throw new import_js_format6.Errorf(
     throw new import_js_format6.Errorf(
       'The first parameter of "parseCookieString" must be a String, but %v was given.',
       'The first parameter of "parseCookieString" must be a String, but %v was given.',
       input
       input
     );
     );
+  }
   return input.split(";").filter((v) => v !== "").map((v) => v.split("=")).reduce((cookies, tuple) => {
   return input.split(";").filter((v) => v !== "").map((v) => v.split("=")).reduce((cookies, tuple) => {
     const key = decodeURIComponent(tuple[0]).trim();
     const key = decodeURIComponent(tuple[0]).trim();
     const value = tuple[1] !== void 0 ? decodeURIComponent(tuple[1]).trim() : "";
     const value = tuple[1] !== void 0 ? decodeURIComponent(tuple[1]).trim() : "";
@@ -337,16 +360,21 @@ var import_js_format8 = require("@e22m4u/js-format");
 // src/utils/create-cookie-string.js
 // src/utils/create-cookie-string.js
 var import_js_format7 = require("@e22m4u/js-format");
 var import_js_format7 = require("@e22m4u/js-format");
 function createCookieString(data) {
 function createCookieString(data) {
-  if (!data || typeof data !== "object" || Array.isArray(data))
+  if (!data || typeof data !== "object" || Array.isArray(data)) {
     throw new import_js_format7.Errorf(
     throw new import_js_format7.Errorf(
       'The first parameter of "createCookieString" must be an Object, but %v was given.',
       'The first parameter of "createCookieString" must be an Object, but %v was given.',
       data
       data
     );
     );
+  }
   let cookies = "";
   let cookies = "";
   for (const key in data) {
   for (const key in data) {
-    if (!Object.prototype.hasOwnProperty.call(data, key)) continue;
+    if (!Object.prototype.hasOwnProperty.call(data, key)) {
+      continue;
+    }
     const val = data[key];
     const val = data[key];
-    if (val == null) continue;
+    if (val == null) {
+      continue;
+    }
     cookies += `${key}=${val}; `;
     cookies += `${key}=${val}; `;
   }
   }
   return cookies.trim();
   return cookies.trim();
@@ -362,26 +390,30 @@ function createRequestMock(patch) {
     );
     );
   }
   }
   patch = patch || {};
   patch = patch || {};
-  if (patch.host != null && typeof patch.host !== "string")
+  if (patch.host != null && typeof patch.host !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "host" of "createRequestMock" must be a String, but %v was given.',
       'The parameter "host" of "createRequestMock" must be a String, but %v was given.',
       patch.host
       patch.host
     );
     );
-  if (patch.method != null && typeof patch.method !== "string")
+  }
+  if (patch.method != null && typeof patch.method !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "method" of "createRequestMock" must be a String, but %v was given.',
       'The parameter "method" of "createRequestMock" must be a String, but %v was given.',
       patch.method
       patch.method
     );
     );
-  if (patch.secure != null && typeof patch.secure !== "boolean")
+  }
+  if (patch.secure != null && typeof patch.secure !== "boolean") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "secure" of "createRequestMock" must be a Boolean, but %v was given.',
       'The parameter "secure" of "createRequestMock" must be a Boolean, but %v was given.',
       patch.secure
       patch.secure
     );
     );
-  if (patch.path != null && typeof patch.path !== "string")
+  }
+  if (patch.path != null && typeof patch.path !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "path" of "createRequestMock" must be a String, but %v was given.',
       'The parameter "path" of "createRequestMock" must be a String, but %v was given.',
       patch.path
       patch.path
     );
     );
+  }
   if (patch.query != null && typeof patch.query !== "object" && typeof patch.query !== "string" || Array.isArray(patch.query)) {
   if (patch.query != null && typeof patch.query !== "object" && typeof patch.query !== "string" || Array.isArray(patch.query)) {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "query" of "createRequestMock" must be a String or Object, but %v was given.',
       'The parameter "query" of "createRequestMock" must be a String or Object, but %v was given.',
@@ -400,36 +432,42 @@ function createRequestMock(patch) {
       patch.headers
       patch.headers
     );
     );
   }
   }
-  if (patch.stream != null && !isReadableStream(patch.stream))
+  if (patch.stream != null && !isReadableStream(patch.stream)) {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "stream" of "createRequestMock" must be a Stream, but %v was given.',
       'The parameter "stream" of "createRequestMock" must be a Stream, but %v was given.',
       patch.stream
       patch.stream
     );
     );
+  }
   if (patch.encoding != null) {
   if (patch.encoding != null) {
-    if (typeof patch.encoding !== "string")
+    if (typeof patch.encoding !== "string") {
       throw new import_js_format8.Errorf(
       throw new import_js_format8.Errorf(
         'The parameter "encoding" of "createRequestMock" must be a String, but %v was given.',
         'The parameter "encoding" of "createRequestMock" must be a String, but %v was given.',
         patch.encoding
         patch.encoding
       );
       );
-    if (!CHARACTER_ENCODING_LIST.includes(patch.encoding))
+    }
+    if (!CHARACTER_ENCODING_LIST.includes(patch.encoding)) {
       throw new import_js_format8.Errorf(
       throw new import_js_format8.Errorf(
         "Character encoding %v is not supported.",
         "Character encoding %v is not supported.",
         patch.encoding
         patch.encoding
       );
       );
+    }
   }
   }
   if (patch.stream) {
   if (patch.stream) {
-    if (patch.secure != null)
+    if (patch.secure != null) {
       throw new import_js_format8.Errorf(
       throw new import_js_format8.Errorf(
         'The "createRequestMock" does not allow specifying the "stream" and "secure" options simultaneously.'
         'The "createRequestMock" does not allow specifying the "stream" and "secure" options simultaneously.'
       );
       );
-    if (patch.body != null)
+    }
+    if (patch.body != null) {
       throw new import_js_format8.Errorf(
       throw new import_js_format8.Errorf(
         'The "createRequestMock" does not allow specifying the "stream" and "body" options simultaneously.'
         'The "createRequestMock" does not allow specifying the "stream" and "body" options simultaneously.'
       );
       );
-    if (patch.encoding != null)
+    }
+    if (patch.encoding != null) {
       throw new import_js_format8.Errorf(
       throw new import_js_format8.Errorf(
         'The "createRequestMock" does not allow specifying the "stream" and "encoding" options simultaneously.'
         'The "createRequestMock" does not allow specifying the "stream" and "encoding" options simultaneously.'
       );
       );
+    }
   }
   }
   const request = patch.stream || createRequestStream(patch.secure, patch.body, patch.encoding);
   const request = patch.stream || createRequestStream(patch.secure, patch.body, patch.encoding);
   request.url = createRequestUrl(patch.path || "/", patch.query);
   request.url = createRequestUrl(patch.path || "/", patch.query);
@@ -446,14 +484,17 @@ function createRequestMock(patch) {
 }
 }
 __name(createRequestMock, "createRequestMock");
 __name(createRequestMock, "createRequestMock");
 function createRequestStream(secure, body, encoding) {
 function createRequestStream(secure, body, encoding) {
-  if (encoding != null && typeof encoding !== "string")
+  if (encoding != null && typeof encoding !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "encoding" of "createRequestStream" must be a String, but %v was given.',
       'The parameter "encoding" of "createRequestStream" must be a String, but %v was given.',
       encoding
       encoding
     );
     );
+  }
   encoding = encoding || "utf-8";
   encoding = encoding || "utf-8";
   let socket = new import_net.Socket();
   let socket = new import_net.Socket();
-  if (secure) socket = new import_tls.TLSSocket(socket);
+  if (secure) {
+    socket = new import_tls.TLSSocket(socket);
+  }
   const request = new import_http2.IncomingMessage(socket);
   const request = new import_http2.IncomingMessage(socket);
   if (body != null) {
   if (body != null) {
     if (typeof body === "string") {
     if (typeof body === "string") {
@@ -469,11 +510,12 @@ function createRequestStream(secure, body, encoding) {
 }
 }
 __name(createRequestStream, "createRequestStream");
 __name(createRequestStream, "createRequestStream");
 function createRequestUrl(path, query) {
 function createRequestUrl(path, query) {
-  if (typeof path !== "string")
+  if (typeof path !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "path" of "createRequestUrl" must be a String, but %v was given.',
       'The parameter "path" of "createRequestUrl" must be a String, but %v was given.',
       path
       path
     );
     );
+  }
   if (query != null && typeof query !== "string" && typeof query !== "object" || Array.isArray(query)) {
   if (query != null && typeof query !== "string" && typeof query !== "object" || Array.isArray(query)) {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "query" of "createRequestUrl" must be a String or Object, but %v was given.',
       'The parameter "query" of "createRequestUrl" must be a String or Object, but %v was given.',
@@ -483,7 +525,9 @@ function createRequestUrl(path, query) {
   let url = ("/" + path).replace("//", "/");
   let url = ("/" + path).replace("//", "/");
   if (typeof query === "object") {
   if (typeof query === "object") {
     const qs = import_querystring.default.stringify(query);
     const qs = import_querystring.default.stringify(query);
-    if (qs) url += `?${qs}`;
+    if (qs) {
+      url += `?${qs}`;
+    }
   } else if (typeof query === "string") {
   } else if (typeof query === "string") {
     url += `?${query.replace(/^\?/, "")}`;
     url += `?${query.replace(/^\?/, "")}`;
   }
   }
@@ -491,17 +535,19 @@ function createRequestUrl(path, query) {
 }
 }
 __name(createRequestUrl, "createRequestUrl");
 __name(createRequestUrl, "createRequestUrl");
 function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
 function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
-  if (host != null && typeof host !== "string")
+  if (host != null && typeof host !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "host" of "createRequestHeaders" a non-empty String, but %v was given.',
       'The parameter "host" of "createRequestHeaders" a non-empty String, but %v was given.',
       host
       host
     );
     );
+  }
   host = host || "localhost";
   host = host || "localhost";
-  if (secure != null && typeof secure !== "boolean")
+  if (secure != null && typeof secure !== "boolean") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "secure" of "createRequestHeaders" must be a String, but %v was given.',
       'The parameter "secure" of "createRequestHeaders" must be a String, but %v was given.',
       secure
       secure
     );
     );
+  }
   secure = Boolean(secure);
   secure = Boolean(secure);
   if (cookies != null && typeof cookies !== "object" && typeof cookies !== "string" || Array.isArray(cookies)) {
   if (cookies != null && typeof cookies !== "object" && typeof cookies !== "string" || Array.isArray(cookies)) {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
@@ -516,15 +562,18 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
     );
     );
   }
   }
   headers = headers || {};
   headers = headers || {};
-  if (encoding != null && typeof encoding !== "string")
+  if (encoding != null && typeof encoding !== "string") {
     throw new import_js_format8.Errorf(
     throw new import_js_format8.Errorf(
       'The parameter "encoding" of "createRequestHeaders" must be a String, but %v was given.',
       'The parameter "encoding" of "createRequestHeaders" must be a String, but %v was given.',
       encoding
       encoding
     );
     );
+  }
   encoding = encoding || "utf-8";
   encoding = encoding || "utf-8";
   const obj = { ...headers };
   const obj = { ...headers };
   obj["host"] = host;
   obj["host"] = host;
-  if (secure) obj["x-forwarded-proto"] = "https";
+  if (secure) {
+    obj["x-forwarded-proto"] = "https";
+  }
   if (cookies != null) {
   if (cookies != null) {
     if (typeof cookies === "string") {
     if (typeof cookies === "string") {
       obj["cookie"] = obj["cookie"] ? obj["cookie"] : "";
       obj["cookie"] = obj["cookie"] ? obj["cookie"] : "";
@@ -612,10 +661,11 @@ function patchHeaders(response) {
   Object.defineProperty(response, "setHeader", {
   Object.defineProperty(response, "setHeader", {
     configurable: true,
     configurable: true,
     value: /* @__PURE__ */ __name(function(name, value) {
     value: /* @__PURE__ */ __name(function(name, value) {
-      if (this.headersSent)
+      if (this.headersSent) {
         throw new Error(
         throw new Error(
           "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client"
           "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client"
         );
         );
+      }
       const key = name.toLowerCase();
       const key = name.toLowerCase();
       this._headers[key] = String(value);
       this._headers[key] = String(value);
       return this;
       return this;
@@ -700,16 +750,19 @@ var _HookRegistry = class _HookRegistry {
    * @returns {this}
    * @returns {this}
    */
    */
   addHook(type, hook) {
   addHook(type, hook) {
-    if (!type || typeof type !== "string")
+    if (!type || typeof type !== "string") {
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
-    if (!hook || typeof hook !== "function")
+    }
+    if (!hook || typeof hook !== "function") {
       throw new import_js_format10.Errorf(
       throw new import_js_format10.Errorf(
         "The hook %v must be a Function, but %v was given.",
         "The hook %v must be a Function, but %v was given.",
         type,
         type,
         hook
         hook
       );
       );
+    }
     const hooks = this._hooks.get(type) || [];
     const hooks = this._hooks.get(type) || [];
     hooks.push(hook);
     hooks.push(hook);
     this._hooks.set(type, hooks);
     this._hooks.set(type, hooks);
@@ -723,16 +776,19 @@ var _HookRegistry = class _HookRegistry {
    * @returns {boolean}
    * @returns {boolean}
    */
    */
   hasHook(type, hook) {
   hasHook(type, hook) {
-    if (!type || typeof type !== "string")
+    if (!type || typeof type !== "string") {
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
-    if (!hook || typeof hook !== "function")
+    }
+    if (!hook || typeof hook !== "function") {
       throw new import_js_format10.Errorf(
       throw new import_js_format10.Errorf(
         "The hook %v must be a Function, but %v was given.",
         "The hook %v must be a Function, but %v was given.",
         type,
         type,
         hook
         hook
       );
       );
+    }
     const hooks = this._hooks.get(type) || [];
     const hooks = this._hooks.get(type) || [];
     return hooks.indexOf(hook) > -1;
     return hooks.indexOf(hook) > -1;
   }
   }
@@ -743,10 +799,12 @@ var _HookRegistry = class _HookRegistry {
    * @returns {Function[]}
    * @returns {Function[]}
    */
    */
   getHooks(type) {
   getHooks(type) {
-    if (!type || typeof type !== "string")
+    if (!type || typeof type !== "string") {
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
       throw new import_js_format10.Errorf("The hook type is required, but %v was given.", type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
       throw new import_js_format10.Errorf("The hook type %v is not supported.", type);
+    }
     return this._hooks.get(type) || [];
     return this._hooks.get(type) || [];
   }
   }
 };
 };
@@ -765,18 +823,21 @@ var _HookInvoker = class _HookInvoker extends DebuggableService {
    * @returns {Promise<*>|*}
    * @returns {Promise<*>|*}
    */
    */
   invokeAndContinueUntilValueReceived(route, hookType, response, ...args) {
   invokeAndContinueUntilValueReceived(route, hookType, response, ...args) {
-    if (!route || !(route instanceof Route))
+    if (!route || !(route instanceof Route)) {
       throw new import_js_format11.Errorf(
       throw new import_js_format11.Errorf(
         'The parameter "route" of the HookInvoker.invokeAndContinueUntilValueReceived must be a Route instance, but %v was given.',
         'The parameter "route" of the HookInvoker.invokeAndContinueUntilValueReceived must be a Route instance, but %v was given.',
         route
         route
       );
       );
-    if (!hookType || typeof hookType !== "string")
+    }
+    if (!hookType || typeof hookType !== "string") {
       throw new import_js_format11.Errorf(
       throw new import_js_format11.Errorf(
         'The parameter "hookType" of the HookInvoker.invokeAndContinueUntilValueReceived must be a non-empty String, but %v was given.',
         'The parameter "hookType" of the HookInvoker.invokeAndContinueUntilValueReceived must be a non-empty String, but %v was given.',
         hookType
         hookType
       );
       );
-    if (!Object.values(RouterHookType).includes(hookType))
+    }
+    if (!Object.values(RouterHookType).includes(hookType)) {
       throw new import_js_format11.Errorf("The hook type %v is not supported.", hookType);
       throw new import_js_format11.Errorf("The hook type %v is not supported.", hookType);
+    }
     if (!response || typeof response !== "object" || Array.isArray(response) || typeof response.headersSent !== "boolean") {
     if (!response || typeof response !== "object" || Array.isArray(response) || typeof response.headersSent !== "boolean") {
       throw new import_js_format11.Errorf(
       throw new import_js_format11.Errorf(
         'The parameter "response" of the HookInvoker.invokeAndContinueUntilValueReceived must be a ServerResponse instance, but %v was given.',
         'The parameter "response" of the HookInvoker.invokeAndContinueUntilValueReceived must be a ServerResponse instance, but %v was given.',
@@ -922,34 +983,39 @@ var _Route = class _Route extends import_js_debug.Debuggable {
       noEnvironmentNamespace: true,
       noEnvironmentNamespace: true,
       noInstantiationMessage: true
       noInstantiationMessage: true
     });
     });
-    if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef))
+    if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef)) {
       throw new import_js_format12.Errorf(
       throw new import_js_format12.Errorf(
         "The first parameter of Route.constructor must be an Object, but %v was given.",
         "The first parameter of Route.constructor must be an Object, but %v was given.",
         routeDef
         routeDef
       );
       );
-    if (!routeDef.method || typeof routeDef.method !== "string")
+    }
+    if (!routeDef.method || typeof routeDef.method !== "string") {
       throw new import_js_format12.Errorf(
       throw new import_js_format12.Errorf(
         'The option "method" of the Route must be a non-empty String, but %v was given.',
         'The option "method" of the Route must be a non-empty String, but %v was given.',
         routeDef.method
         routeDef.method
       );
       );
+    }
     this._method = routeDef.method.toUpperCase();
     this._method = routeDef.method.toUpperCase();
-    if (typeof routeDef.path !== "string")
+    if (typeof routeDef.path !== "string") {
       throw new import_js_format12.Errorf(
       throw new import_js_format12.Errorf(
         'The option "path" of the Route must be a String, but %v was given.',
         'The option "path" of the Route must be a String, but %v was given.',
         routeDef.path
         routeDef.path
       );
       );
+    }
     this._path = routeDef.path;
     this._path = routeDef.path;
-    if (typeof routeDef.handler !== "function")
+    if (typeof routeDef.handler !== "function") {
       throw new import_js_format12.Errorf(
       throw new import_js_format12.Errorf(
         'The option "handler" of the Route must be a Function, but %v was given.',
         'The option "handler" of the Route must be a Function, but %v was given.',
         routeDef.handler
         routeDef.handler
       );
       );
+    }
     if (routeDef.meta != null) {
     if (routeDef.meta != null) {
-      if (typeof routeDef.meta !== "object" || Array.isArray(routeDef.meta))
+      if (typeof routeDef.meta !== "object" || Array.isArray(routeDef.meta)) {
         throw new import_js_format12.Errorf(
         throw new import_js_format12.Errorf(
           'The option "meta" of the Route must be a plain Object, but %v was given.',
           'The option "meta" of the Route must be a plain Object, but %v was given.',
           routeDef.meta
           routeDef.meta
         );
         );
+      }
       this._meta = cloneDeep(routeDef.meta);
       this._meta = cloneDeep(routeDef.meta);
     }
     }
     this._handler = routeDef.handler;
     this._handler = routeDef.handler;
@@ -1017,11 +1083,12 @@ var _RouterOptions = class _RouterOptions extends DebuggableService {
    * @returns {RouterOptions}
    * @returns {RouterOptions}
    */
    */
   setRequestBodyBytesLimit(input) {
   setRequestBodyBytesLimit(input) {
-    if (typeof input !== "number" || input < 0)
+    if (typeof input !== "number" || input < 0) {
       throw new import_js_format13.Errorf(
       throw new import_js_format13.Errorf(
         'The option "requestBodyBytesLimit" must be a positive Number or 0, but %v was given.',
         'The option "requestBodyBytesLimit" must be a positive Number or 0, but %v was given.',
         input
         input
       );
       );
+    }
     this._requestBodyBytesLimit = input;
     this._requestBodyBytesLimit = input;
     return this;
     return this;
   }
   }
@@ -1050,16 +1117,18 @@ var _BodyParser = class _BodyParser extends DebuggableService {
    * @returns {this}
    * @returns {this}
    */
    */
   defineParser(mediaType, parser) {
   defineParser(mediaType, parser) {
-    if (!mediaType || typeof mediaType !== "string")
+    if (!mediaType || typeof mediaType !== "string") {
       throw new import_js_format14.Errorf(
       throw new import_js_format14.Errorf(
         'The parameter "mediaType" of BodyParser.defineParser must be a non-empty String, but %v was given.',
         'The parameter "mediaType" of BodyParser.defineParser must be a non-empty String, but %v was given.',
         mediaType
         mediaType
       );
       );
-    if (!parser || typeof parser !== "function")
+    }
+    if (!parser || typeof parser !== "function") {
       throw new import_js_format14.Errorf(
       throw new import_js_format14.Errorf(
         'The parameter "parser" of BodyParser.defineParser must be a Function, but %v was given.',
         'The parameter "parser" of BodyParser.defineParser must be a Function, but %v was given.',
         parser
         parser
       );
       );
+    }
     this._parsers[mediaType] = parser;
     this._parsers[mediaType] = parser;
     return this;
     return this;
   }
   }
@@ -1070,11 +1139,12 @@ var _BodyParser = class _BodyParser extends DebuggableService {
    * @returns {boolean}
    * @returns {boolean}
    */
    */
   hasParser(mediaType) {
   hasParser(mediaType) {
-    if (!mediaType || typeof mediaType !== "string")
+    if (!mediaType || typeof mediaType !== "string") {
       throw new import_js_format14.Errorf(
       throw new import_js_format14.Errorf(
         'The parameter "mediaType" of BodyParser.hasParser must be a non-empty String, but %v was given.',
         'The parameter "mediaType" of BodyParser.hasParser must be a non-empty String, but %v was given.',
         mediaType
         mediaType
       );
       );
+    }
     return Boolean(this._parsers[mediaType]);
     return Boolean(this._parsers[mediaType]);
   }
   }
   /**
   /**
@@ -1084,13 +1154,16 @@ var _BodyParser = class _BodyParser extends DebuggableService {
    * @returns {this}
    * @returns {this}
    */
    */
   deleteParser(mediaType) {
   deleteParser(mediaType) {
-    if (!mediaType || typeof mediaType !== "string")
+    if (!mediaType || typeof mediaType !== "string") {
       throw new import_js_format14.Errorf(
       throw new import_js_format14.Errorf(
         'The parameter "mediaType" of BodyParser.deleteParser must be a non-empty String, but %v was given.',
         'The parameter "mediaType" of BodyParser.deleteParser must be a non-empty String, but %v was given.',
         mediaType
         mediaType
       );
       );
+    }
     const parser = this._parsers[mediaType];
     const parser = this._parsers[mediaType];
-    if (!parser) throw new import_js_format14.Errorf("The parser of %v is not found.", mediaType);
+    if (!parser) {
+      throw new import_js_format14.Errorf("The parser of %v is not found.", mediaType);
+    }
     delete this._parsers[mediaType];
     delete this._parsers[mediaType];
     return this;
     return this;
   }
   }
@@ -1120,11 +1193,12 @@ var _BodyParser = class _BodyParser extends DebuggableService {
       return;
       return;
     }
     }
     const { mediaType } = parseContentType(contentType);
     const { mediaType } = parseContentType(contentType);
-    if (!mediaType)
+    if (!mediaType) {
       throw createError(
       throw createError(
         import_http_errors2.default.BadRequest,
         import_http_errors2.default.BadRequest,
         'Unable to parse the "content-type" header.'
         'Unable to parse the "content-type" header.'
       );
       );
+    }
     const parser = this._parsers[mediaType];
     const parser = this._parsers[mediaType];
     if (!parser) {
     if (!parser) {
       if (UNPARSABLE_MEDIA_TYPES.includes(mediaType)) {
       if (UNPARSABLE_MEDIA_TYPES.includes(mediaType)) {
@@ -1139,7 +1213,9 @@ var _BodyParser = class _BodyParser extends DebuggableService {
     }
     }
     const bodyBytesLimit = this.getService(RouterOptions).requestBodyBytesLimit;
     const bodyBytesLimit = this.getService(RouterOptions).requestBodyBytesLimit;
     return fetchRequestBody(request, bodyBytesLimit).then((rawBody) => {
     return fetchRequestBody(request, bodyBytesLimit).then((rawBody) => {
-      if (rawBody != null) return parser(rawBody);
+      if (rawBody != null) {
+        return parser(rawBody);
+      }
       return rawBody;
       return rawBody;
     });
     });
   }
   }
@@ -1147,7 +1223,9 @@ var _BodyParser = class _BodyParser extends DebuggableService {
 __name(_BodyParser, "BodyParser");
 __name(_BodyParser, "BodyParser");
 var BodyParser = _BodyParser;
 var BodyParser = _BodyParser;
 function parseJsonBody(input) {
 function parseJsonBody(input) {
-  if (typeof input !== "string") return void 0;
+  if (typeof input !== "string") {
+    return void 0;
+  }
   try {
   try {
     return JSON.parse(input);
     return JSON.parse(input);
   } catch (error) {
   } catch (error) {
@@ -1228,11 +1306,12 @@ var _RequestParser = class _RequestParser extends DebuggableService {
    * @returns {Promise<object>|object}
    * @returns {Promise<object>|object}
    */
    */
   parse(request) {
   parse(request) {
-    if (!(request instanceof import_http3.IncomingMessage))
+    if (!(request instanceof import_http3.IncomingMessage)) {
       throw new import_js_format15.Errorf(
       throw new import_js_format15.Errorf(
         "The first parameter of RequestParser.parse must be an instance of IncomingMessage, but %v was given.",
         "The first parameter of RequestParser.parse must be an instance of IncomingMessage, but %v was given.",
         request
         request
       );
       );
+    }
     const data = {};
     const data = {};
     const promises = [];
     const promises = [];
     const parsedQuery = this.getService(QueryParser).parse(request);
     const parsedQuery = this.getService(QueryParser).parse(request);
@@ -1282,11 +1361,12 @@ var _RouteRegistry = class _RouteRegistry extends DebuggableService {
    */
    */
   defineRoute(routeDef) {
   defineRoute(routeDef) {
     const debug = this.getDebuggerFor(this.defineRoute);
     const debug = this.getDebuggerFor(this.defineRoute);
-    if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef))
+    if (!routeDef || typeof routeDef !== "object" || Array.isArray(routeDef)) {
       throw new import_js_format16.Errorf(
       throw new import_js_format16.Errorf(
         "The route definition must be an Object, but %v was given.",
         "The route definition must be an Object, but %v was given.",
         routeDef
         routeDef
       );
       );
+    }
     const route = new Route(routeDef);
     const route = new Route(routeDef);
     const triePath = `${route.method}/${route.path}`;
     const triePath = `${route.method}/${route.path}`;
     this._trie.add(triePath, route);
     this._trie.add(triePath, route);
@@ -1478,7 +1558,9 @@ var _RequestContext = class _RequestContext {
    * @returns {string}
    * @returns {string}
    */
    */
   get pathname() {
   get pathname() {
-    if (this._pathname != null) return this._pathname;
+    if (this._pathname != null) {
+      return this._pathname;
+    }
     this._pathname = getRequestPathname(this.request);
     this._pathname = getRequestPathname(this.request);
     return this._pathname;
     return this._pathname;
   }
   }
@@ -1491,11 +1573,12 @@ var _RequestContext = class _RequestContext {
    * @param {Route} route
    * @param {Route} route
    */
    */
   constructor(container, request, response, route) {
   constructor(container, request, response, route) {
-    if (!(0, import_js_service3.isServiceContainer)(container))
+    if (!(0, import_js_service3.isServiceContainer)(container)) {
       throw new import_js_format17.Errorf(
       throw new import_js_format17.Errorf(
         'The parameter "container" of RequestContext.constructor must be an instance of ServiceContainer, but %v was given.',
         'The parameter "container" of RequestContext.constructor must be an instance of ServiceContainer, but %v was given.',
         container
         container
       );
       );
+    }
     this._container = container;
     this._container = container;
     if (!request || typeof request !== "object" || Array.isArray(request) || !isReadableStream(request)) {
     if (!request || typeof request !== "object" || Array.isArray(request) || !isReadableStream(request)) {
       throw new import_js_format17.Errorf(
       throw new import_js_format17.Errorf(
@@ -1615,7 +1698,9 @@ var _ErrorSender = class _ErrorSender extends DebuggableService {
       body.error.message = (0, import_statuses.default)(statusCode);
       body.error.message = (0, import_statuses.default)(statusCode);
     }
     }
     EXPOSED_ERROR_PROPERTIES.forEach((name) => {
     EXPOSED_ERROR_PROPERTIES.forEach((name) => {
-      if (name in safeError) body.error[name] = safeError[name];
+      if (name in safeError) {
+        body.error[name] = safeError[name];
+      }
     });
     });
     const requestData = {
     const requestData = {
       url: request.url,
       url: request.url,
@@ -1763,10 +1848,14 @@ var _TrieRouter = class _TrieRouter extends DebuggableService {
           response,
           response,
           context
           context
         );
         );
-        if (isPromise(data)) data = await data;
+        if (isPromise(data)) {
+          data = await data;
+        }
         if (!isResponseSent(response) && data == null) {
         if (!isResponseSent(response) && data == null) {
           data = route.handle(context);
           data = route.handle(context);
-          if (isPromise(data)) data = await data;
+          if (isPromise(data)) {
+            data = await data;
+          }
           let postHandlerData = hookInvoker.invokeAndContinueUntilValueReceived(
           let postHandlerData = hookInvoker.invokeAndContinueUntilValueReceived(
             route,
             route,
             RouterHookType.POST_HANDLER,
             RouterHookType.POST_HANDLER,
@@ -1774,9 +1863,12 @@ var _TrieRouter = class _TrieRouter extends DebuggableService {
             context,
             context,
             data
             data
           );
           );
-          if (isPromise(postHandlerData))
+          if (isPromise(postHandlerData)) {
             postHandlerData = await postHandlerData;
             postHandlerData = await postHandlerData;
-          if (postHandlerData != null) data = postHandlerData;
+          }
+          if (postHandlerData != null) {
+            data = postHandlerData;
+          }
         }
         }
       } catch (error) {
       } catch (error) {
         this.getService(ErrorSender).send(request, response, error);
         this.getService(ErrorSender).send(request, response, error);

+ 1 - 0
eslint.config.js

@@ -27,6 +27,7 @@ export default [{
     ...eslintMochaPlugin.configs.recommended.rules,
     ...eslintMochaPlugin.configs.recommended.rules,
     ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
     ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
     ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
     ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
+    "curly": "error",
     'no-duplicate-imports': 'error',
     'no-duplicate-imports': 'error',
     'import/export': 0,
     'import/export': 0,
     'jsdoc/reject-any-type': 0,
     'jsdoc/reject-any-type': 0,

+ 6 - 3
src/hooks/hook-invoker.js

@@ -18,22 +18,25 @@ export class HookInvoker extends DebuggableService {
    * @returns {Promise<*>|*}
    * @returns {Promise<*>|*}
    */
    */
   invokeAndContinueUntilValueReceived(route, hookType, response, ...args) {
   invokeAndContinueUntilValueReceived(route, hookType, response, ...args) {
-    if (!route || !(route instanceof Route))
+    if (!route || !(route instanceof Route)) {
       throw new Errorf(
       throw new Errorf(
         'The parameter "route" of ' +
         'The parameter "route" of ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
           'must be a Route instance, but %v was given.',
           'must be a Route instance, but %v was given.',
         route,
         route,
       );
       );
-    if (!hookType || typeof hookType !== 'string')
+    }
+    if (!hookType || typeof hookType !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "hookType" of ' +
         'The parameter "hookType" of ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
           'the HookInvoker.invokeAndContinueUntilValueReceived ' +
           'must be a non-empty String, but %v was given.',
           'must be a non-empty String, but %v was given.',
         hookType,
         hookType,
       );
       );
-    if (!Object.values(RouterHookType).includes(hookType))
+    }
+    if (!Object.values(RouterHookType).includes(hookType)) {
       throw new Errorf('The hook type %v is not supported.', hookType);
       throw new Errorf('The hook type %v is not supported.', hookType);
+    }
     if (
     if (
       !response ||
       !response ||
       typeof response !== 'object' ||
       typeof response !== 'object' ||

+ 16 - 8
src/hooks/hook-registry.js

@@ -33,16 +33,19 @@ export class HookRegistry {
    * @returns {this}
    * @returns {this}
    */
    */
   addHook(type, hook) {
   addHook(type, hook) {
-    if (!type || typeof type !== 'string')
+    if (!type || typeof type !== 'string') {
       throw new Errorf('The hook type is required, but %v was given.', type);
       throw new Errorf('The hook type is required, but %v was given.', type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new Errorf('The hook type %v is not supported.', type);
       throw new Errorf('The hook type %v is not supported.', type);
-    if (!hook || typeof hook !== 'function')
+    }
+    if (!hook || typeof hook !== 'function') {
       throw new Errorf(
       throw new Errorf(
         'The hook %v must be a Function, but %v was given.',
         'The hook %v must be a Function, but %v was given.',
         type,
         type,
         hook,
         hook,
       );
       );
+    }
     const hooks = this._hooks.get(type) || [];
     const hooks = this._hooks.get(type) || [];
     hooks.push(hook);
     hooks.push(hook);
     this._hooks.set(type, hooks);
     this._hooks.set(type, hooks);
@@ -57,16 +60,19 @@ export class HookRegistry {
    * @returns {boolean}
    * @returns {boolean}
    */
    */
   hasHook(type, hook) {
   hasHook(type, hook) {
-    if (!type || typeof type !== 'string')
+    if (!type || typeof type !== 'string') {
       throw new Errorf('The hook type is required, but %v was given.', type);
       throw new Errorf('The hook type is required, but %v was given.', type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new Errorf('The hook type %v is not supported.', type);
       throw new Errorf('The hook type %v is not supported.', type);
-    if (!hook || typeof hook !== 'function')
+    }
+    if (!hook || typeof hook !== 'function') {
       throw new Errorf(
       throw new Errorf(
         'The hook %v must be a Function, but %v was given.',
         'The hook %v must be a Function, but %v was given.',
         type,
         type,
         hook,
         hook,
       );
       );
+    }
     const hooks = this._hooks.get(type) || [];
     const hooks = this._hooks.get(type) || [];
     return hooks.indexOf(hook) > -1;
     return hooks.indexOf(hook) > -1;
   }
   }
@@ -78,10 +84,12 @@ export class HookRegistry {
    * @returns {Function[]}
    * @returns {Function[]}
    */
    */
   getHooks(type) {
   getHooks(type) {
-    if (!type || typeof type !== 'string')
+    if (!type || typeof type !== 'string') {
       throw new Errorf('The hook type is required, but %v was given.', type);
       throw new Errorf('The hook type is required, but %v was given.', type);
-    if (!Object.values(RouterHookType).includes(type))
+    }
+    if (!Object.values(RouterHookType).includes(type)) {
       throw new Errorf('The hook type %v is not supported.', type);
       throw new Errorf('The hook type %v is not supported.', type);
+    }
     return this._hooks.get(type) || [];
     return this._hooks.get(type) || [];
   }
   }
 }
 }

+ 19 - 8
src/parsers/body-parser.js

@@ -45,18 +45,20 @@ export class BodyParser extends DebuggableService {
    * @returns {this}
    * @returns {this}
    */
    */
   defineParser(mediaType, parser) {
   defineParser(mediaType, parser) {
-    if (!mediaType || typeof mediaType !== 'string')
+    if (!mediaType || typeof mediaType !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.defineParser ' +
         'The parameter "mediaType" of BodyParser.defineParser ' +
           'must be a non-empty String, but %v was given.',
           'must be a non-empty String, but %v was given.',
         mediaType,
         mediaType,
       );
       );
-    if (!parser || typeof parser !== 'function')
+    }
+    if (!parser || typeof parser !== 'function') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "parser" of BodyParser.defineParser ' +
         'The parameter "parser" of BodyParser.defineParser ' +
           'must be a Function, but %v was given.',
           'must be a Function, but %v was given.',
         parser,
         parser,
       );
       );
+    }
     this._parsers[mediaType] = parser;
     this._parsers[mediaType] = parser;
     return this;
     return this;
   }
   }
@@ -68,12 +70,13 @@ export class BodyParser extends DebuggableService {
    * @returns {boolean}
    * @returns {boolean}
    */
    */
   hasParser(mediaType) {
   hasParser(mediaType) {
-    if (!mediaType || typeof mediaType !== 'string')
+    if (!mediaType || typeof mediaType !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.hasParser ' +
         'The parameter "mediaType" of BodyParser.hasParser ' +
           'must be a non-empty String, but %v was given.',
           'must be a non-empty String, but %v was given.',
         mediaType,
         mediaType,
       );
       );
+    }
     return Boolean(this._parsers[mediaType]);
     return Boolean(this._parsers[mediaType]);
   }
   }
 
 
@@ -84,14 +87,17 @@ export class BodyParser extends DebuggableService {
    * @returns {this}
    * @returns {this}
    */
    */
   deleteParser(mediaType) {
   deleteParser(mediaType) {
-    if (!mediaType || typeof mediaType !== 'string')
+    if (!mediaType || typeof mediaType !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "mediaType" of BodyParser.deleteParser ' +
         'The parameter "mediaType" of BodyParser.deleteParser ' +
           'must be a non-empty String, but %v was given.',
           'must be a non-empty String, but %v was given.',
         mediaType,
         mediaType,
       );
       );
+    }
     const parser = this._parsers[mediaType];
     const parser = this._parsers[mediaType];
-    if (!parser) throw new Errorf('The parser of %v is not found.', mediaType);
+    if (!parser) {
+      throw new Errorf('The parser of %v is not found.', mediaType);
+    }
     delete this._parsers[mediaType];
     delete this._parsers[mediaType];
     return this;
     return this;
   }
   }
@@ -122,11 +128,12 @@ export class BodyParser extends DebuggableService {
       return;
       return;
     }
     }
     const {mediaType} = parseContentType(contentType);
     const {mediaType} = parseContentType(contentType);
-    if (!mediaType)
+    if (!mediaType) {
       throw createError(
       throw createError(
         HttpErrors.BadRequest,
         HttpErrors.BadRequest,
         'Unable to parse the "content-type" header.',
         'Unable to parse the "content-type" header.',
       );
       );
+    }
     const parser = this._parsers[mediaType];
     const parser = this._parsers[mediaType];
     if (!parser) {
     if (!parser) {
       if (UNPARSABLE_MEDIA_TYPES.includes(mediaType)) {
       if (UNPARSABLE_MEDIA_TYPES.includes(mediaType)) {
@@ -141,7 +148,9 @@ export class BodyParser extends DebuggableService {
     }
     }
     const bodyBytesLimit = this.getService(RouterOptions).requestBodyBytesLimit;
     const bodyBytesLimit = this.getService(RouterOptions).requestBodyBytesLimit;
     return fetchRequestBody(request, bodyBytesLimit).then(rawBody => {
     return fetchRequestBody(request, bodyBytesLimit).then(rawBody => {
-      if (rawBody != null) return parser(rawBody);
+      if (rawBody != null) {
+        return parser(rawBody);
+      }
       return rawBody;
       return rawBody;
     });
     });
   }
   }
@@ -154,7 +163,9 @@ export class BodyParser extends DebuggableService {
  * @returns {*|undefined}
  * @returns {*|undefined}
  */
  */
 export function parseJsonBody(input) {
 export function parseJsonBody(input) {
-  if (typeof input !== 'string') return undefined;
+  if (typeof input !== 'string') {
+    return undefined;
+  }
   try {
   try {
     return JSON.parse(input);
     return JSON.parse(input);
   } catch (error) {
   } catch (error) {

+ 2 - 1
src/parsers/request-parser.js

@@ -17,12 +17,13 @@ export class RequestParser extends DebuggableService {
    * @returns {Promise<object>|object}
    * @returns {Promise<object>|object}
    */
    */
   parse(request) {
   parse(request) {
-    if (!(request instanceof IncomingMessage))
+    if (!(request instanceof IncomingMessage)) {
       throw new Errorf(
       throw new Errorf(
         'The first parameter of RequestParser.parse must be ' +
         'The first parameter of RequestParser.parse must be ' +
           'an instance of IncomingMessage, but %v was given.',
           'an instance of IncomingMessage, but %v was given.',
         request,
         request,
       );
       );
+    }
     const data = {};
     const data = {};
     const promises = [];
     const promises = [];
     // парсинг "query" выполняется с проверкой
     // парсинг "query" выполняется с проверкой

+ 5 - 2
src/request-context.js

@@ -159,7 +159,9 @@ export class RequestContext {
    * @returns {string}
    * @returns {string}
    */
    */
   get pathname() {
   get pathname() {
-    if (this._pathname != null) return this._pathname;
+    if (this._pathname != null) {
+      return this._pathname;
+    }
     this._pathname = getRequestPathname(this.request);
     this._pathname = getRequestPathname(this.request);
     return this._pathname;
     return this._pathname;
   }
   }
@@ -173,12 +175,13 @@ export class RequestContext {
    * @param {Route} route
    * @param {Route} route
    */
    */
   constructor(container, request, response, route) {
   constructor(container, request, response, route) {
-    if (!isServiceContainer(container))
+    if (!isServiceContainer(container)) {
       throw new Errorf(
       throw new Errorf(
         'The parameter "container" of RequestContext.constructor ' +
         'The parameter "container" of RequestContext.constructor ' +
           'must be an instance of ServiceContainer, but %v was given.',
           'must be an instance of ServiceContainer, but %v was given.',
         container,
         container,
       );
       );
+    }
     this._container = container;
     this._container = container;
     if (
     if (
       !request ||
       !request ||

+ 2 - 1
src/route-registry.js

@@ -33,11 +33,12 @@ export class RouteRegistry extends DebuggableService {
    */
    */
   defineRoute(routeDef) {
   defineRoute(routeDef) {
     const debug = this.getDebuggerFor(this.defineRoute);
     const debug = this.getDebuggerFor(this.defineRoute);
-    if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef))
+    if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef)) {
       throw new Errorf(
       throw new Errorf(
         'The route definition must be an Object, but %v was given.',
         'The route definition must be an Object, but %v was given.',
         routeDef,
         routeDef,
       );
       );
+    }
     const route = new Route(routeDef);
     const route = new Route(routeDef);
     const triePath = `${route.method}/${route.path}`;
     const triePath = `${route.method}/${route.path}`;
     this._trie.add(triePath, route);
     this._trie.add(triePath, route);

+ 10 - 5
src/route.js

@@ -137,39 +137,44 @@ export class Route extends Debuggable {
       noEnvironmentNamespace: true,
       noEnvironmentNamespace: true,
       noInstantiationMessage: true,
       noInstantiationMessage: true,
     });
     });
-    if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef))
+    if (!routeDef || typeof routeDef !== 'object' || Array.isArray(routeDef)) {
       throw new Errorf(
       throw new Errorf(
         'The first parameter of Route.constructor ' +
         'The first parameter of Route.constructor ' +
           'must be an Object, but %v was given.',
           'must be an Object, but %v was given.',
         routeDef,
         routeDef,
       );
       );
-    if (!routeDef.method || typeof routeDef.method !== 'string')
+    }
+    if (!routeDef.method || typeof routeDef.method !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The option "method" of the Route must be ' +
         'The option "method" of the Route must be ' +
           'a non-empty String, but %v was given.',
           'a non-empty String, but %v was given.',
         routeDef.method,
         routeDef.method,
       );
       );
+    }
     this._method = routeDef.method.toUpperCase();
     this._method = routeDef.method.toUpperCase();
-    if (typeof routeDef.path !== 'string')
+    if (typeof routeDef.path !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The option "path" of the Route must be ' +
         'The option "path" of the Route must be ' +
           'a String, but %v was given.',
           'a String, but %v was given.',
         routeDef.path,
         routeDef.path,
       );
       );
+    }
     this._path = routeDef.path;
     this._path = routeDef.path;
-    if (typeof routeDef.handler !== 'function')
+    if (typeof routeDef.handler !== 'function') {
       throw new Errorf(
       throw new Errorf(
         'The option "handler" of the Route must be ' +
         'The option "handler" of the Route must be ' +
           'a Function, but %v was given.',
           'a Function, but %v was given.',
         routeDef.handler,
         routeDef.handler,
       );
       );
+    }
     if (routeDef.meta != null) {
     if (routeDef.meta != null) {
-      if (typeof routeDef.meta !== 'object' || Array.isArray(routeDef.meta))
+      if (typeof routeDef.meta !== 'object' || Array.isArray(routeDef.meta)) {
         throw new Errorf(
         throw new Errorf(
           'The option "meta" of the Route must be ' +
           'The option "meta" of the Route must be ' +
             'a plain Object, but %v was given.',
             'a plain Object, but %v was given.',
           routeDef.meta,
           routeDef.meta,
         );
         );
+      }
       this._meta = cloneDeep(routeDef.meta);
       this._meta = cloneDeep(routeDef.meta);
     }
     }
     this._handler = routeDef.handler;
     this._handler = routeDef.handler;

+ 2 - 1
src/router-options.js

@@ -29,12 +29,13 @@ export class RouterOptions extends DebuggableService {
    * @returns {RouterOptions}
    * @returns {RouterOptions}
    */
    */
   setRequestBodyBytesLimit(input) {
   setRequestBodyBytesLimit(input) {
-    if (typeof input !== 'number' || input < 0)
+    if (typeof input !== 'number' || input < 0) {
       throw new Errorf(
       throw new Errorf(
         'The option "requestBodyBytesLimit" must be ' +
         'The option "requestBodyBytesLimit" must be ' +
           'a positive Number or 0, but %v was given.',
           'a positive Number or 0, but %v was given.',
         input,
         input,
       );
       );
+    }
     this._requestBodyBytesLimit = input;
     this._requestBodyBytesLimit = input;
     return this;
     return this;
   }
   }

+ 3 - 1
src/senders/error-sender.js

@@ -40,7 +40,9 @@ export class ErrorSender extends DebuggableService {
       body.error.message = getStatusMessage(statusCode);
       body.error.message = getStatusMessage(statusCode);
     }
     }
     EXPOSED_ERROR_PROPERTIES.forEach(name => {
     EXPOSED_ERROR_PROPERTIES.forEach(name => {
-      if (name in safeError) body.error[name] = safeError[name];
+      if (name in safeError) {
+        body.error[name] = safeError[name];
+      }
     });
     });
     const requestData = {
     const requestData = {
       url: request.url,
       url: request.url,

+ 11 - 4
src/trie-router.js

@@ -134,14 +134,18 @@ export class TrieRouter extends DebuggableService {
           response,
           response,
           context,
           context,
         );
         );
-        if (isPromise(data)) data = await data;
+        if (isPromise(data)) {
+          data = await data;
+        }
         // если ответ не бы отправлен внутри "preHandler" хуков,
         // если ответ не бы отправлен внутри "preHandler" хуков,
         // и сами "preHandler" хуки не вернули значения, то вызывается
         // и сами "preHandler" хуки не вернули значения, то вызывается
         // основной обработчик маршрута, результат которого передается
         // основной обработчик маршрута, результат которого передается
         // в хуки "postHandler"
         // в хуки "postHandler"
         if (!isResponseSent(response) && data == null) {
         if (!isResponseSent(response) && data == null) {
           data = route.handle(context);
           data = route.handle(context);
-          if (isPromise(data)) data = await data;
+          if (isPromise(data)) {
+            data = await data;
+          }
           // вызываются хуки "postHandler", результат которых
           // вызываются хуки "postHandler", результат которых
           // также может быть использован в качестве ответа
           // также может быть использован в качестве ответа
           let postHandlerData = hookInvoker.invokeAndContinueUntilValueReceived(
           let postHandlerData = hookInvoker.invokeAndContinueUntilValueReceived(
@@ -151,9 +155,12 @@ export class TrieRouter extends DebuggableService {
             context,
             context,
             data,
             data,
           );
           );
-          if (isPromise(postHandlerData))
+          if (isPromise(postHandlerData)) {
             postHandlerData = await postHandlerData;
             postHandlerData = await postHandlerData;
-          if (postHandlerData != null) data = postHandlerData;
+          }
+          if (postHandlerData != null) {
+            data = postHandlerData;
+          }
         }
         }
       } catch (error) {
       } catch (error) {
         this.getService(ErrorSender).send(request, response, error);
         this.getService(ErrorSender).send(request, response, error);

+ 8 - 3
src/utils/create-cookie-string.js

@@ -7,17 +7,22 @@ import {Errorf} from '@e22m4u/js-format';
  * @returns {string}
  * @returns {string}
  */
  */
 export function createCookieString(data) {
 export function createCookieString(data) {
-  if (!data || typeof data !== 'object' || Array.isArray(data))
+  if (!data || typeof data !== 'object' || Array.isArray(data)) {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of "createCookieString" must be ' +
       'The first parameter of "createCookieString" must be ' +
         'an Object, but %v was given.',
         'an Object, but %v was given.',
       data,
       data,
     );
     );
+  }
   let cookies = '';
   let cookies = '';
   for (const key in data) {
   for (const key in data) {
-    if (!Object.prototype.hasOwnProperty.call(data, key)) continue;
+    if (!Object.prototype.hasOwnProperty.call(data, key)) {
+      continue;
+    }
     const val = data[key];
     const val = data[key];
-    if (val == null) continue;
+    if (val == null) {
+      continue;
+    }
     cookies += `${key}=${val}; `;
     cookies += `${key}=${val}; `;
   }
   }
   return cookies.trim();
   return cookies.trim();

+ 7 - 3
src/utils/create-error.js

@@ -9,19 +9,23 @@ import {format, Errorf} from '@e22m4u/js-format';
  * @returns {object}
  * @returns {object}
  */
  */
 export function createError(errorCtor, message, ...args) {
 export function createError(errorCtor, message, ...args) {
-  if (typeof errorCtor !== 'function')
+  if (typeof errorCtor !== 'function') {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of "createError" must be ' +
       'The first parameter of "createError" must be ' +
         'a constructor, but %v was given.',
         'a constructor, but %v was given.',
       errorCtor,
       errorCtor,
     );
     );
-  if (message != null && typeof message !== 'string')
+  }
+  if (message != null && typeof message !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The second parameter of "createError" must be ' +
       'The second parameter of "createError" must be ' +
         'a String, but %v was given.',
         'a String, but %v was given.',
       message,
       message,
     );
     );
-  if (message == null) return new errorCtor();
+  }
+  if (message == null) {
+    return new errorCtor();
+  }
   const interpolatedMessage = format(message, ...args);
   const interpolatedMessage = format(message, ...args);
   return new errorCtor(interpolatedMessage);
   return new errorCtor(interpolatedMessage);
 }
 }

+ 39 - 18
src/utils/create-request-mock.js

@@ -37,30 +37,34 @@ export function createRequestMock(patch) {
     );
     );
   }
   }
   patch = patch || {};
   patch = patch || {};
-  if (patch.host != null && typeof patch.host !== 'string')
+  if (patch.host != null && typeof patch.host !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "host" of "createRequestMock" ' +
       'The parameter "host" of "createRequestMock" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       patch.host,
       patch.host,
     );
     );
-  if (patch.method != null && typeof patch.method !== 'string')
+  }
+  if (patch.method != null && typeof patch.method !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "method" of "createRequestMock" ' +
       'The parameter "method" of "createRequestMock" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       patch.method,
       patch.method,
     );
     );
-  if (patch.secure != null && typeof patch.secure !== 'boolean')
+  }
+  if (patch.secure != null && typeof patch.secure !== 'boolean') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "secure" of "createRequestMock" ' +
       'The parameter "secure" of "createRequestMock" ' +
         'must be a Boolean, but %v was given.',
         'must be a Boolean, but %v was given.',
       patch.secure,
       patch.secure,
     );
     );
-  if (patch.path != null && typeof patch.path !== 'string')
+  }
+  if (patch.path != null && typeof patch.path !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "path" of "createRequestMock" ' +
       'The parameter "path" of "createRequestMock" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       patch.path,
       patch.path,
     );
     );
+  }
   if (
   if (
     (patch.query != null &&
     (patch.query != null &&
       typeof patch.query !== 'object' &&
       typeof patch.query !== 'object' &&
@@ -95,43 +99,49 @@ export function createRequestMock(patch) {
       patch.headers,
       patch.headers,
     );
     );
   }
   }
-  if (patch.stream != null && !isReadableStream(patch.stream))
+  if (patch.stream != null && !isReadableStream(patch.stream)) {
     throw new Errorf(
     throw new Errorf(
       'The parameter "stream" of "createRequestMock" ' +
       'The parameter "stream" of "createRequestMock" ' +
         'must be a Stream, but %v was given.',
         'must be a Stream, but %v was given.',
       patch.stream,
       patch.stream,
     );
     );
+  }
   if (patch.encoding != null) {
   if (patch.encoding != null) {
-    if (typeof patch.encoding !== 'string')
+    if (typeof patch.encoding !== 'string') {
       throw new Errorf(
       throw new Errorf(
         'The parameter "encoding" of "createRequestMock" ' +
         'The parameter "encoding" of "createRequestMock" ' +
           'must be a String, but %v was given.',
           'must be a String, but %v was given.',
         patch.encoding,
         patch.encoding,
       );
       );
-    if (!CHARACTER_ENCODING_LIST.includes(patch.encoding))
+    }
+    if (!CHARACTER_ENCODING_LIST.includes(patch.encoding)) {
       throw new Errorf(
       throw new Errorf(
         'Character encoding %v is not supported.',
         'Character encoding %v is not supported.',
         patch.encoding,
         patch.encoding,
       );
       );
+    }
   }
   }
   // если передан поток, выполняется
   // если передан поток, выполняется
   // проверка на несовместимые опции
   // проверка на несовместимые опции
   if (patch.stream) {
   if (patch.stream) {
-    if (patch.secure != null)
+    if (patch.secure != null) {
       throw new Errorf(
       throw new Errorf(
         'The "createRequestMock" does not allow specifying the ' +
         'The "createRequestMock" does not allow specifying the ' +
           '"stream" and "secure" options simultaneously.',
           '"stream" and "secure" options simultaneously.',
       );
       );
-    if (patch.body != null)
+    }
+    if (patch.body != null) {
       throw new Errorf(
       throw new Errorf(
         'The "createRequestMock" does not allow specifying the ' +
         'The "createRequestMock" does not allow specifying the ' +
           '"stream" and "body" options simultaneously.',
           '"stream" and "body" options simultaneously.',
       );
       );
-    if (patch.encoding != null)
+    }
+    if (patch.encoding != null) {
       throw new Errorf(
       throw new Errorf(
         'The "createRequestMock" does not allow specifying the ' +
         'The "createRequestMock" does not allow specifying the ' +
           '"stream" and "encoding" options simultaneously.',
           '"stream" and "encoding" options simultaneously.',
       );
       );
+    }
   }
   }
   // если передан поток, он будет использован
   // если передан поток, он будет использован
   // в качестве объекта запроса, в противном
   // в качестве объекта запроса, в противном
@@ -161,17 +171,20 @@ export function createRequestMock(patch) {
  * @returns {import('http').IncomingMessage}
  * @returns {import('http').IncomingMessage}
  */
  */
 function createRequestStream(secure, body, encoding) {
 function createRequestStream(secure, body, encoding) {
-  if (encoding != null && typeof encoding !== 'string')
+  if (encoding != null && typeof encoding !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "encoding" of "createRequestStream" ' +
       'The parameter "encoding" of "createRequestStream" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       encoding,
       encoding,
     );
     );
+  }
   encoding = encoding || 'utf-8';
   encoding = encoding || 'utf-8';
   // для безопасного подключения
   // для безопасного подключения
   // использует обертка TLSSocket
   // использует обертка TLSSocket
   let socket = new Socket();
   let socket = new Socket();
-  if (secure) socket = new TLSSocket(socket);
+  if (secure) {
+    socket = new TLSSocket(socket);
+  }
   const request = new IncomingMessage(socket);
   const request = new IncomingMessage(socket);
   // тело запроса должно являться
   // тело запроса должно являться
   // строкой или бинарными данными
   // строкой или бинарными данными
@@ -198,12 +211,13 @@ function createRequestStream(secure, body, encoding) {
  * @returns {string}
  * @returns {string}
  */
  */
 function createRequestUrl(path, query) {
 function createRequestUrl(path, query) {
-  if (typeof path !== 'string')
+  if (typeof path !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "path" of "createRequestUrl" ' +
       'The parameter "path" of "createRequestUrl" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       path,
       path,
     );
     );
+  }
   if (
   if (
     (query != null && typeof query !== 'string' && typeof query !== 'object') ||
     (query != null && typeof query !== 'string' && typeof query !== 'object') ||
     Array.isArray(query)
     Array.isArray(query)
@@ -217,7 +231,9 @@ function createRequestUrl(path, query) {
   let url = ('/' + path).replace('//', '/');
   let url = ('/' + path).replace('//', '/');
   if (typeof query === 'object') {
   if (typeof query === 'object') {
     const qs = queryString.stringify(query);
     const qs = queryString.stringify(query);
-    if (qs) url += `?${qs}`;
+    if (qs) {
+      url += `?${qs}`;
+    }
   } else if (typeof query === 'string') {
   } else if (typeof query === 'string') {
     url += `?${query.replace(/^\?/, '')}`;
     url += `?${query.replace(/^\?/, '')}`;
   }
   }
@@ -236,19 +252,21 @@ function createRequestUrl(path, query) {
  * @returns {object}
  * @returns {object}
  */
  */
 function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
 function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
-  if (host != null && typeof host !== 'string')
+  if (host != null && typeof host !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "host" of "createRequestHeaders" ' +
       'The parameter "host" of "createRequestHeaders" ' +
         'a non-empty String, but %v was given.',
         'a non-empty String, but %v was given.',
       host,
       host,
     );
     );
+  }
   host = host || 'localhost';
   host = host || 'localhost';
-  if (secure != null && typeof secure !== 'boolean')
+  if (secure != null && typeof secure !== 'boolean') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "secure" of "createRequestHeaders" ' +
       'The parameter "secure" of "createRequestHeaders" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       secure,
       secure,
     );
     );
+  }
   secure = Boolean(secure);
   secure = Boolean(secure);
   if (
   if (
     (cookies != null &&
     (cookies != null &&
@@ -273,16 +291,19 @@ function createRequestHeaders(host, secure, body, cookies, encoding, headers) {
     );
     );
   }
   }
   headers = headers || {};
   headers = headers || {};
-  if (encoding != null && typeof encoding !== 'string')
+  if (encoding != null && typeof encoding !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "encoding" of "createRequestHeaders" ' +
       'The parameter "encoding" of "createRequestHeaders" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       encoding,
       encoding,
     );
     );
+  }
   encoding = encoding || 'utf-8';
   encoding = encoding || 'utf-8';
   const obj = {...headers};
   const obj = {...headers};
   obj['host'] = host;
   obj['host'] = host;
-  if (secure) obj['x-forwarded-proto'] = 'https';
+  if (secure) {
+    obj['x-forwarded-proto'] = 'https';
+  }
   // формирование заголовка Cookie
   // формирование заголовка Cookie
   // из строки или объекта
   // из строки или объекта
   if (cookies != null) {
   if (cookies != null) {

+ 2 - 1
src/utils/create-response-mock.js

@@ -64,11 +64,12 @@ function patchHeaders(response) {
   Object.defineProperty(response, 'setHeader', {
   Object.defineProperty(response, 'setHeader', {
     configurable: true,
     configurable: true,
     value: function (name, value) {
     value: function (name, value) {
-      if (this.headersSent)
+      if (this.headersSent) {
         throw new Error(
         throw new Error(
           'Error [ERR_HTTP_HEADERS_SENT]: ' +
           'Error [ERR_HTTP_HEADERS_SENT]: ' +
             'Cannot set headers after they are sent to the client',
             'Cannot set headers after they are sent to the client',
         );
         );
+      }
       const key = name.toLowerCase();
       const key = name.toLowerCase();
       this._headers[key] = String(value);
       this._headers[key] = String(value);
       return this;
       return this;

+ 8 - 4
src/utils/fetch-request-body.js

@@ -26,18 +26,20 @@ export const CHARACTER_ENCODING_LIST = [
  * @returns {Promise<string|undefined>}
  * @returns {Promise<string|undefined>}
  */
  */
 export function fetchRequestBody(request, bodyBytesLimit = 0) {
 export function fetchRequestBody(request, bodyBytesLimit = 0) {
-  if (!(request instanceof IncomingMessage))
+  if (!(request instanceof IncomingMessage)) {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of "fetchRequestBody" must be ' +
       'The first parameter of "fetchRequestBody" must be ' +
         'an IncomingMessage instance, but %v was given.',
         'an IncomingMessage instance, but %v was given.',
       request,
       request,
     );
     );
-  if (typeof bodyBytesLimit !== 'number')
+  }
+  if (typeof bodyBytesLimit !== 'number') {
     throw new Errorf(
     throw new Errorf(
       'The parameter "bodyBytesLimit" of "fetchRequestBody" ' +
       'The parameter "bodyBytesLimit" of "fetchRequestBody" ' +
         'must be a number, but %v was given.',
         'must be a number, but %v was given.',
       bodyBytesLimit,
       bodyBytesLimit,
     );
     );
+  }
   return new Promise((resolve, reject) => {
   return new Promise((resolve, reject) => {
     // сравнение внутреннего ограничения
     // сравнение внутреннего ограничения
     // размера тела запроса с заголовком
     // размера тела запроса с заголовком
@@ -46,13 +48,14 @@ export function fetchRequestBody(request, bodyBytesLimit = 0) {
       request.headers['content-length'] || '0',
       request.headers['content-length'] || '0',
       10,
       10,
     );
     );
-    if (bodyBytesLimit && contentLength && contentLength > bodyBytesLimit)
+    if (bodyBytesLimit && contentLength && contentLength > bodyBytesLimit) {
       throw createError(
       throw createError(
         HttpErrors.PayloadTooLarge,
         HttpErrors.PayloadTooLarge,
         'Request body limit is %s bytes, but %s bytes given.',
         'Request body limit is %s bytes, but %s bytes given.',
         bodyBytesLimit,
         bodyBytesLimit,
         contentLength,
         contentLength,
       );
       );
+    }
     // определение кодировки
     // определение кодировки
     // по заголовку "content-type"
     // по заголовку "content-type"
     let encoding = 'utf-8';
     let encoding = 'utf-8';
@@ -61,12 +64,13 @@ export function fetchRequestBody(request, bodyBytesLimit = 0) {
       const parsedContentType = parseContentType(contentType);
       const parsedContentType = parseContentType(contentType);
       if (parsedContentType && parsedContentType.charset) {
       if (parsedContentType && parsedContentType.charset) {
         encoding = parsedContentType.charset.toLowerCase();
         encoding = parsedContentType.charset.toLowerCase();
-        if (!CHARACTER_ENCODING_LIST.includes(encoding))
+        if (!CHARACTER_ENCODING_LIST.includes(encoding)) {
           throw createError(
           throw createError(
             HttpErrors.UnsupportedMediaType,
             HttpErrors.UnsupportedMediaType,
             'Request encoding %v is not supported.',
             'Request encoding %v is not supported.',
             encoding,
             encoding,
           );
           );
+        }
       }
       }
     }
     }
     // подготовка массива загружаемых байтов
     // подготовка массива загружаемых байтов

+ 6 - 2
src/utils/is-promise.js

@@ -7,7 +7,11 @@
  * @returns {boolean}
  * @returns {boolean}
  */
  */
 export function isPromise(value) {
 export function isPromise(value) {
-  if (!value) return false;
-  if (typeof value !== 'object') return false;
+  if (!value) {
+    return false;
+  }
+  if (typeof value !== 'object') {
+    return false;
+  }
   return typeof value.then === 'function';
   return typeof value.then === 'function';
 }
 }

+ 3 - 1
src/utils/is-readable-stream.js

@@ -5,6 +5,8 @@
  * @returns {boolean}
  * @returns {boolean}
  */
  */
 export function isReadableStream(value) {
 export function isReadableStream(value) {
-  if (!value || typeof value !== 'object') return false;
+  if (!value || typeof value !== 'object') {
+    return false;
+  }
   return typeof value.pipe === 'function';
   return typeof value.pipe === 'function';
 }
 }

+ 3 - 1
src/utils/is-writable-stream.js

@@ -6,6 +6,8 @@
  * @returns {boolean}
  * @returns {boolean}
  */
  */
 export function isWritableStream(value) {
 export function isWritableStream(value) {
-  if (!value || typeof value !== 'object') return false;
+  if (!value || typeof value !== 'object') {
+    return false;
+  }
   return typeof value.end === 'function';
   return typeof value.end === 'function';
 }
 }

+ 8 - 3
src/utils/parse-content-type.js

@@ -11,20 +11,25 @@ import {Errorf} from '@e22m4u/js-format';
  * }}
  * }}
  */
  */
 export function parseContentType(input) {
 export function parseContentType(input) {
-  if (typeof input !== 'string')
+  if (typeof input !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of `parseContentType` ' +
       'The first parameter of `parseContentType` ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       input,
       input,
     );
     );
+  }
   const res = {mediaType: undefined, charset: undefined, boundary: undefined};
   const res = {mediaType: undefined, charset: undefined, boundary: undefined};
   const re =
   const re =
     /^\s*([^\s;/]+\/[^\s;/]+)(?:;\s*charset=([^\s;]+))?(?:;\s*boundary=([^\s;]+))?.*$/i;
     /^\s*([^\s;/]+\/[^\s;/]+)(?:;\s*charset=([^\s;]+))?(?:;\s*boundary=([^\s;]+))?.*$/i;
   const matches = re.exec(input);
   const matches = re.exec(input);
   if (matches && matches[1]) {
   if (matches && matches[1]) {
     res.mediaType = matches[1];
     res.mediaType = matches[1];
-    if (matches[2]) res.charset = matches[2];
-    if (matches[3]) res.boundary = matches[3];
+    if (matches[2]) {
+      res.charset = matches[2];
+    }
+    if (matches[3]) {
+      res.boundary = matches[3];
+    }
   }
   }
   return res;
   return res;
 }
 }

+ 2 - 1
src/utils/parse-cookie-string.js

@@ -13,12 +13,13 @@ import {Errorf} from '@e22m4u/js-format';
  * @returns {object}
  * @returns {object}
  */
  */
 export function parseCookieString(input) {
 export function parseCookieString(input) {
-  if (typeof input !== 'string')
+  if (typeof input !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of "parseCookieString" must be a String, ' +
       'The first parameter of "parseCookieString" must be a String, ' +
         'but %v was given.',
         'but %v was given.',
       input,
       input,
     );
     );
+  }
   return input
   return input
     .split(';')
     .split(';')
     .filter(v => v !== '')
     .filter(v => v !== '')

+ 2 - 1
src/utils/to-camel-case.js

@@ -7,12 +7,13 @@ import {Errorf} from '@e22m4u/js-format';
  * @returns {string}
  * @returns {string}
  */
  */
 export function toCamelCase(input) {
 export function toCamelCase(input) {
-  if (typeof input !== 'string')
+  if (typeof input !== 'string') {
     throw new Errorf(
     throw new Errorf(
       'The first parameter of "toCamelCase" ' +
       'The first parameter of "toCamelCase" ' +
         'must be a String, but %v was given.',
         'must be a String, but %v was given.',
       input,
       input,
     );
     );
+  }
   return input
   return input
     .replace(/(^\w|[A-Z]|\b\w)/g, c => c.toUpperCase())
     .replace(/(^\w|[A-Z]|\b\w)/g, c => c.toUpperCase())
     .replace(/\W+/g, '')
     .replace(/\W+/g, '')