node-server-engine 1.0.5

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.
Files changed (772) hide show
  1. package/.env.example +191 -0
  2. package/.mocharc.js +13 -0
  3. package/.nycrc +18 -0
  4. package/.prettierrc +7 -0
  5. package/Dockerfile +31 -0
  6. package/README.md +960 -0
  7. package/babel.config.json +35 -0
  8. package/dist/const/DebeziumEvent.d.ts +6 -0
  9. package/dist/const/DebeziumEvent.js +14 -0
  10. package/dist/const/DebeziumEvent.js.map +1 -0
  11. package/dist/const/LogSeverity.d.ts +7 -0
  12. package/dist/const/LogSeverity.js +15 -0
  13. package/dist/const/LogSeverity.js.map +1 -0
  14. package/dist/const/index.d.ts +5 -0
  15. package/dist/const/index.js +61 -0
  16. package/dist/const/index.js.map +1 -0
  17. package/dist/const/metrics.d.ts +3 -0
  18. package/dist/const/metrics.js +12 -0
  19. package/dist/const/metrics.js.map +1 -0
  20. package/dist/const/mime.d.ts +9 -0
  21. package/dist/const/mime.js +16 -0
  22. package/dist/const/mime.js.map +1 -0
  23. package/dist/const/tokenIssuer.d.ts +8 -0
  24. package/dist/const/tokenIssuer.js +14 -0
  25. package/dist/const/tokenIssuer.js.map +1 -0
  26. package/dist/db/migrations/20241030121500-create-sequelize-meta-table.d.ts +3 -0
  27. package/dist/db/migrations/20241030121500-create-sequelize-meta-table.js +32 -0
  28. package/dist/db/migrations/20241030121500-create-sequelize-meta-table.js.map +1 -0
  29. package/dist/db/models/SequelizeMeta.d.ts +5 -0
  30. package/dist/db/models/SequelizeMeta.js +48 -0
  31. package/dist/db/models/SequelizeMeta.js.map +1 -0
  32. package/dist/db/models/index.d.ts +1 -0
  33. package/dist/db/models/index.js +17 -0
  34. package/dist/db/models/index.js.map +1 -0
  35. package/dist/entities/ElasticSearch/ElasticSearch.d.ts +15 -0
  36. package/dist/entities/ElasticSearch/ElasticSearch.js +114 -0
  37. package/dist/entities/ElasticSearch/ElasticSearch.js.map +1 -0
  38. package/dist/entities/ElasticSearch/ElasticSearch.types.d.ts +6 -0
  39. package/dist/entities/ElasticSearch/ElasticSearch.types.js +2 -0
  40. package/dist/entities/ElasticSearch/ElasticSearch.types.js.map +1 -0
  41. package/dist/entities/ElasticSearch/index.d.ts +2 -0
  42. package/dist/entities/ElasticSearch/index.js +28 -0
  43. package/dist/entities/ElasticSearch/index.js.map +1 -0
  44. package/dist/entities/Endpoint/Endpoint.d.ts +39 -0
  45. package/dist/entities/Endpoint/Endpoint.js +174 -0
  46. package/dist/entities/Endpoint/Endpoint.js.map +1 -0
  47. package/dist/entities/Endpoint/Endpoint.types.d.ts +133 -0
  48. package/dist/entities/Endpoint/Endpoint.types.js +63 -0
  49. package/dist/entities/Endpoint/Endpoint.types.js.map +1 -0
  50. package/dist/entities/Endpoint/index.d.ts +2 -0
  51. package/dist/entities/Endpoint/index.js +28 -0
  52. package/dist/entities/Endpoint/index.js.map +1 -0
  53. package/dist/entities/EngineError/EngineError.d.ts +17 -0
  54. package/dist/entities/EngineError/EngineError.js +46 -0
  55. package/dist/entities/EngineError/EngineError.js.map +1 -0
  56. package/dist/entities/EngineError/EngineError.types.d.ts +14 -0
  57. package/dist/entities/EngineError/EngineError.types.js +2 -0
  58. package/dist/entities/EngineError/EngineError.types.js.map +1 -0
  59. package/dist/entities/EngineError/index.d.ts +2 -0
  60. package/dist/entities/EngineError/index.js +28 -0
  61. package/dist/entities/EngineError/index.js.map +1 -0
  62. package/dist/entities/KeySet/KeySet.d.ts +33 -0
  63. package/dist/entities/KeySet/KeySet.js +201 -0
  64. package/dist/entities/KeySet/KeySet.js.map +1 -0
  65. package/dist/entities/KeySet/KeySet.types.d.ts +25 -0
  66. package/dist/entities/KeySet/KeySet.types.js +2 -0
  67. package/dist/entities/KeySet/KeySet.types.js.map +1 -0
  68. package/dist/entities/KeySet/index.d.ts +2 -0
  69. package/dist/entities/KeySet/index.js +28 -0
  70. package/dist/entities/KeySet/index.js.map +1 -0
  71. package/dist/entities/LifecycleController/LifecycleController.d.ts +10 -0
  72. package/dist/entities/LifecycleController/LifecycleController.js +28 -0
  73. package/dist/entities/LifecycleController/LifecycleController.js.map +1 -0
  74. package/dist/entities/LifecycleController/LifecycleController.types.d.ts +5 -0
  75. package/dist/entities/LifecycleController/LifecycleController.types.js +2 -0
  76. package/dist/entities/LifecycleController/LifecycleController.types.js.map +1 -0
  77. package/dist/entities/LifecycleController/index.d.ts +2 -0
  78. package/dist/entities/LifecycleController/index.js +28 -0
  79. package/dist/entities/LifecycleController/index.js.map +1 -0
  80. package/dist/entities/Localizator/Localizator.d.ts +28 -0
  81. package/dist/entities/Localizator/Localizator.js +128 -0
  82. package/dist/entities/Localizator/Localizator.js.map +1 -0
  83. package/dist/entities/Localizator/Localizator.types.d.ts +48 -0
  84. package/dist/entities/Localizator/Localizator.types.js +2 -0
  85. package/dist/entities/Localizator/Localizator.types.js.map +1 -0
  86. package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.d.ts +8 -0
  87. package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.js +48 -0
  88. package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.js.map +1 -0
  89. package/dist/entities/Localizator/guessNamingConvention/index.d.ts +1 -0
  90. package/dist/entities/Localizator/guessNamingConvention/index.js +17 -0
  91. package/dist/entities/Localizator/guessNamingConvention/index.js.map +1 -0
  92. package/dist/entities/Localizator/index.d.ts +2 -0
  93. package/dist/entities/Localizator/index.js +28 -0
  94. package/dist/entities/Localizator/index.js.map +1 -0
  95. package/dist/entities/MessageHandler/MessageHandler.d.ts +20 -0
  96. package/dist/entities/MessageHandler/MessageHandler.js +65 -0
  97. package/dist/entities/MessageHandler/MessageHandler.js.map +1 -0
  98. package/dist/entities/MessageHandler/MessageHandler.types.d.ts +10 -0
  99. package/dist/entities/MessageHandler/MessageHandler.types.js +2 -0
  100. package/dist/entities/MessageHandler/MessageHandler.types.js.map +1 -0
  101. package/dist/entities/MessageHandler/index.d.ts +2 -0
  102. package/dist/entities/MessageHandler/index.js +28 -0
  103. package/dist/entities/MessageHandler/index.js.map +1 -0
  104. package/dist/entities/PubSub/PubSub.d.ts +36 -0
  105. package/dist/entities/PubSub/PubSub.js +167 -0
  106. package/dist/entities/PubSub/PubSub.js.map +1 -0
  107. package/dist/entities/PubSub/PubSub.types.d.ts +61 -0
  108. package/dist/entities/PubSub/PubSub.types.js +2 -0
  109. package/dist/entities/PubSub/PubSub.types.js.map +1 -0
  110. package/dist/entities/PubSub/handleMessage/handleMessage.d.ts +10 -0
  111. package/dist/entities/PubSub/handleMessage/handleMessage.js +63 -0
  112. package/dist/entities/PubSub/handleMessage/handleMessage.js.map +1 -0
  113. package/dist/entities/PubSub/handleMessage/index.d.ts +1 -0
  114. package/dist/entities/PubSub/handleMessage/index.js +17 -0
  115. package/dist/entities/PubSub/handleMessage/index.js.map +1 -0
  116. package/dist/entities/PubSub/index.d.ts +2 -0
  117. package/dist/entities/PubSub/index.js +28 -0
  118. package/dist/entities/PubSub/index.js.map +1 -0
  119. package/dist/entities/PushNotification/PushNotification.d.ts +11 -0
  120. package/dist/entities/PushNotification/PushNotification.js +44 -0
  121. package/dist/entities/PushNotification/PushNotification.js.map +1 -0
  122. package/dist/entities/PushNotification/PushNotification.types.d.ts +25 -0
  123. package/dist/entities/PushNotification/PushNotification.types.js +2 -0
  124. package/dist/entities/PushNotification/PushNotification.types.js.map +1 -0
  125. package/dist/entities/PushNotification/index.d.ts +2 -0
  126. package/dist/entities/PushNotification/index.js +28 -0
  127. package/dist/entities/PushNotification/index.js.map +1 -0
  128. package/dist/entities/Redis/Redis.d.ts +19 -0
  129. package/dist/entities/Redis/Redis.js +75 -0
  130. package/dist/entities/Redis/Redis.js.map +1 -0
  131. package/dist/entities/Redis/Redis.types.d.ts +16 -0
  132. package/dist/entities/Redis/Redis.types.js +2 -0
  133. package/dist/entities/Redis/Redis.types.js.map +1 -0
  134. package/dist/entities/Redis/Redis.validate.d.ts +5 -0
  135. package/dist/entities/Redis/Redis.validate.js +21 -0
  136. package/dist/entities/Redis/Redis.validate.js.map +1 -0
  137. package/dist/entities/Redis/index.d.ts +2 -0
  138. package/dist/entities/Redis/index.js +35 -0
  139. package/dist/entities/Redis/index.js.map +1 -0
  140. package/dist/entities/Sequelize/Sequelize.config.d.ts +7 -0
  141. package/dist/entities/Sequelize/Sequelize.config.js +32 -0
  142. package/dist/entities/Sequelize/Sequelize.config.js.map +1 -0
  143. package/dist/entities/Sequelize/Sequelize.d.ts +14 -0
  144. package/dist/entities/Sequelize/Sequelize.js +70 -0
  145. package/dist/entities/Sequelize/Sequelize.js.map +1 -0
  146. package/dist/entities/Sequelize/Sequelize.types.d.ts +9 -0
  147. package/dist/entities/Sequelize/Sequelize.types.js +2 -0
  148. package/dist/entities/Sequelize/Sequelize.types.js.map +1 -0
  149. package/dist/entities/Sequelize/Sequelize.validate.d.ts +4 -0
  150. package/dist/entities/Sequelize/Sequelize.validate.js +27 -0
  151. package/dist/entities/Sequelize/Sequelize.validate.js.map +1 -0
  152. package/dist/entities/Sequelize/index.d.ts +2 -0
  153. package/dist/entities/Sequelize/index.js +28 -0
  154. package/dist/entities/Sequelize/index.js.map +1 -0
  155. package/dist/entities/Server/Server.const.d.ts +5 -0
  156. package/dist/entities/Server/Server.const.js +45 -0
  157. package/dist/entities/Server/Server.const.js.map +1 -0
  158. package/dist/entities/Server/Server.d.ts +61 -0
  159. package/dist/entities/Server/Server.js +380 -0
  160. package/dist/entities/Server/Server.js.map +1 -0
  161. package/dist/entities/Server/Server.types.d.ts +75 -0
  162. package/dist/entities/Server/Server.types.js +2 -0
  163. package/dist/entities/Server/Server.types.js.map +1 -0
  164. package/dist/entities/Server/index.d.ts +2 -0
  165. package/dist/entities/Server/index.js +28 -0
  166. package/dist/entities/Server/index.js.map +1 -0
  167. package/dist/entities/SocketClient/SocketClient.d.ts +79 -0
  168. package/dist/entities/SocketClient/SocketClient.js +394 -0
  169. package/dist/entities/SocketClient/SocketClient.js.map +1 -0
  170. package/dist/entities/SocketClient/SocketClient.types.d.ts +53 -0
  171. package/dist/entities/SocketClient/SocketClient.types.js +2 -0
  172. package/dist/entities/SocketClient/SocketClient.types.js.map +1 -0
  173. package/dist/entities/SocketClient/index.d.ts +2 -0
  174. package/dist/entities/SocketClient/index.js +28 -0
  175. package/dist/entities/SocketClient/index.js.map +1 -0
  176. package/dist/entities/SocketClient/parseMessage/index.d.ts +1 -0
  177. package/dist/entities/SocketClient/parseMessage/index.js +17 -0
  178. package/dist/entities/SocketClient/parseMessage/index.js.map +1 -0
  179. package/dist/entities/SocketClient/parseMessage/parseMessage.d.ts +5 -0
  180. package/dist/entities/SocketClient/parseMessage/parseMessage.js +34 -0
  181. package/dist/entities/SocketClient/parseMessage/parseMessage.js.map +1 -0
  182. package/dist/entities/Storage/Storage.d.ts +38 -0
  183. package/dist/entities/Storage/Storage.js +214 -0
  184. package/dist/entities/Storage/Storage.js.map +1 -0
  185. package/dist/entities/Storage/Storage.types.d.ts +52 -0
  186. package/dist/entities/Storage/Storage.types.js +2 -0
  187. package/dist/entities/Storage/Storage.types.js.map +1 -0
  188. package/dist/entities/Storage/index.d.ts +2 -0
  189. package/dist/entities/Storage/index.js +28 -0
  190. package/dist/entities/Storage/index.js.map +1 -0
  191. package/dist/entities/ValidationError/ValidationError.d.ts +7 -0
  192. package/dist/entities/ValidationError/ValidationError.js +44 -0
  193. package/dist/entities/ValidationError/ValidationError.js.map +1 -0
  194. package/dist/entities/ValidationError/index.d.ts +1 -0
  195. package/dist/entities/ValidationError/index.js +17 -0
  196. package/dist/entities/ValidationError/index.js.map +1 -0
  197. package/dist/entities/WebError/WebError.d.ts +15 -0
  198. package/dist/entities/WebError/WebError.js +42 -0
  199. package/dist/entities/WebError/WebError.js.map +1 -0
  200. package/dist/entities/WebError/WebError.types.d.ts +8 -0
  201. package/dist/entities/WebError/WebError.types.js +2 -0
  202. package/dist/entities/WebError/WebError.types.js.map +1 -0
  203. package/dist/entities/WebError/index.d.ts +2 -0
  204. package/dist/entities/WebError/index.js +28 -0
  205. package/dist/entities/WebError/index.js.map +1 -0
  206. package/dist/entities/index.d.ts +16 -0
  207. package/dist/entities/index.js +182 -0
  208. package/dist/entities/index.js.map +1 -0
  209. package/dist/index.d.ts +4 -0
  210. package/dist/index.js +50 -0
  211. package/dist/index.js.map +1 -0
  212. package/dist/metrics/debug.d.ts +2 -0
  213. package/dist/metrics/debug.js +15 -0
  214. package/dist/metrics/debug.js.map +1 -0
  215. package/dist/metrics/index.d.ts +2 -0
  216. package/dist/metrics/index.js +28 -0
  217. package/dist/metrics/index.js.map +1 -0
  218. package/dist/metrics/request.d.ts +3 -0
  219. package/dist/metrics/request.js +22 -0
  220. package/dist/metrics/request.js.map +1 -0
  221. package/dist/middleware/authAdmin/authAdmin.d.ts +4 -0
  222. package/dist/middleware/authAdmin/authAdmin.js +105 -0
  223. package/dist/middleware/authAdmin/authAdmin.js.map +1 -0
  224. package/dist/middleware/authAdmin/authAdmin.types.d.ts +16 -0
  225. package/dist/middleware/authAdmin/authAdmin.types.js +2 -0
  226. package/dist/middleware/authAdmin/authAdmin.types.js.map +1 -0
  227. package/dist/middleware/authAdmin/index.d.ts +2 -0
  228. package/dist/middleware/authAdmin/index.js +28 -0
  229. package/dist/middleware/authAdmin/index.js.map +1 -0
  230. package/dist/middleware/authHmac/authHmac.d.ts +4 -0
  231. package/dist/middleware/authHmac/authHmac.js +57 -0
  232. package/dist/middleware/authHmac/authHmac.js.map +1 -0
  233. package/dist/middleware/authHmac/authHmac.types.d.ts +7 -0
  234. package/dist/middleware/authHmac/authHmac.types.js +2 -0
  235. package/dist/middleware/authHmac/authHmac.types.js.map +1 -0
  236. package/dist/middleware/authHmac/index.d.ts +2 -0
  237. package/dist/middleware/authHmac/index.js +28 -0
  238. package/dist/middleware/authHmac/index.js.map +1 -0
  239. package/dist/middleware/authJwt/authJwt.d.ts +3 -0
  240. package/dist/middleware/authJwt/authJwt.js +56 -0
  241. package/dist/middleware/authJwt/authJwt.js.map +1 -0
  242. package/dist/middleware/authJwt/authJwt.types.d.ts +22 -0
  243. package/dist/middleware/authJwt/authJwt.types.js +2 -0
  244. package/dist/middleware/authJwt/authJwt.types.js.map +1 -0
  245. package/dist/middleware/authJwt/index.d.ts +2 -0
  246. package/dist/middleware/authJwt/index.js +28 -0
  247. package/dist/middleware/authJwt/index.js.map +1 -0
  248. package/dist/middleware/authStatic/authStatic.d.ts +6 -0
  249. package/dist/middleware/authStatic/authStatic.js +54 -0
  250. package/dist/middleware/authStatic/authStatic.js.map +1 -0
  251. package/dist/middleware/authStatic/index.d.ts +1 -0
  252. package/dist/middleware/authStatic/index.js +17 -0
  253. package/dist/middleware/authStatic/index.js.map +1 -0
  254. package/dist/middleware/authTls/authTls.d.ts +16 -0
  255. package/dist/middleware/authTls/authTls.js +102 -0
  256. package/dist/middleware/authTls/authTls.js.map +1 -0
  257. package/dist/middleware/authTls/authTls.types.d.ts +10 -0
  258. package/dist/middleware/authTls/authTls.types.js +6 -0
  259. package/dist/middleware/authTls/authTls.types.js.map +1 -0
  260. package/dist/middleware/authTls/index.d.ts +2 -0
  261. package/dist/middleware/authTls/index.js +18 -0
  262. package/dist/middleware/authTls/index.js.map +1 -0
  263. package/dist/middleware/error/error.d.ts +3 -0
  264. package/dist/middleware/error/error.js +34 -0
  265. package/dist/middleware/error/error.js.map +1 -0
  266. package/dist/middleware/error/index.d.ts +1 -0
  267. package/dist/middleware/error/index.js +17 -0
  268. package/dist/middleware/error/index.js.map +1 -0
  269. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.d.ts +6 -0
  270. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js +28 -0
  271. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js.map +1 -0
  272. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.d.ts +12 -0
  273. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.js +2 -0
  274. package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.js.map +1 -0
  275. package/dist/middleware/fileUploader/compressAvatar/index.d.ts +2 -0
  276. package/dist/middleware/fileUploader/compressAvatar/index.js +28 -0
  277. package/dist/middleware/fileUploader/compressAvatar/index.js.map +1 -0
  278. package/dist/middleware/fileUploader/fileUploader.d.ts +10 -0
  279. package/dist/middleware/fileUploader/fileUploader.js +296 -0
  280. package/dist/middleware/fileUploader/fileUploader.js.map +1 -0
  281. package/dist/middleware/fileUploader/fileUploader.types.d.ts +49 -0
  282. package/dist/middleware/fileUploader/fileUploader.types.js +2 -0
  283. package/dist/middleware/fileUploader/fileUploader.types.js.map +1 -0
  284. package/dist/middleware/fileUploader/index.d.ts +2 -0
  285. package/dist/middleware/fileUploader/index.js +28 -0
  286. package/dist/middleware/fileUploader/index.js.map +1 -0
  287. package/dist/middleware/fileUploader/isMultiPart/index.d.ts +1 -0
  288. package/dist/middleware/fileUploader/isMultiPart/index.js +17 -0
  289. package/dist/middleware/fileUploader/isMultiPart/index.js.map +1 -0
  290. package/dist/middleware/fileUploader/isMultiPart/isMultipart.d.ts +3 -0
  291. package/dist/middleware/fileUploader/isMultiPart/isMultipart.js +14 -0
  292. package/dist/middleware/fileUploader/isMultiPart/isMultipart.js.map +1 -0
  293. package/dist/middleware/fileUploader/validate/index.d.ts +1 -0
  294. package/dist/middleware/fileUploader/validate/index.js +17 -0
  295. package/dist/middleware/fileUploader/validate/index.js.map +1 -0
  296. package/dist/middleware/fileUploader/validate/validate.d.ts +4 -0
  297. package/dist/middleware/fileUploader/validate/validate.js +28 -0
  298. package/dist/middleware/fileUploader/validate/validate.js.map +1 -0
  299. package/dist/middleware/fourOhFour/fourOhFour.d.ts +3 -0
  300. package/dist/middleware/fourOhFour/fourOhFour.js +18 -0
  301. package/dist/middleware/fourOhFour/fourOhFour.js.map +1 -0
  302. package/dist/middleware/fourOhFour/index.d.ts +1 -0
  303. package/dist/middleware/fourOhFour/index.js +17 -0
  304. package/dist/middleware/fourOhFour/index.js.map +1 -0
  305. package/dist/middleware/healthCheck/healthCheck.d.ts +5 -0
  306. package/dist/middleware/healthCheck/healthCheck.js +18 -0
  307. package/dist/middleware/healthCheck/healthCheck.js.map +1 -0
  308. package/dist/middleware/healthCheck/index.d.ts +1 -0
  309. package/dist/middleware/healthCheck/index.js +17 -0
  310. package/dist/middleware/healthCheck/index.js.map +1 -0
  311. package/dist/middleware/index.d.ts +15 -0
  312. package/dist/middleware/index.js +171 -0
  313. package/dist/middleware/index.js.map +1 -0
  314. package/dist/middleware/metrics/index.d.ts +1 -0
  315. package/dist/middleware/metrics/index.js +17 -0
  316. package/dist/middleware/metrics/index.js.map +1 -0
  317. package/dist/middleware/metrics/metrics.d.ts +3 -0
  318. package/dist/middleware/metrics/metrics.js +28 -0
  319. package/dist/middleware/metrics/metrics.js.map +1 -0
  320. package/dist/middleware/requestMetrics/index.d.ts +1 -0
  321. package/dist/middleware/requestMetrics/index.js +17 -0
  322. package/dist/middleware/requestMetrics/index.js.map +1 -0
  323. package/dist/middleware/requestMetrics/requestMetrics.d.ts +2 -0
  324. package/dist/middleware/requestMetrics/requestMetrics.js +21 -0
  325. package/dist/middleware/requestMetrics/requestMetrics.js.map +1 -0
  326. package/dist/middleware/swaggerDocs/index.d.ts +2 -0
  327. package/dist/middleware/swaggerDocs/index.js +28 -0
  328. package/dist/middleware/swaggerDocs/index.js.map +1 -0
  329. package/dist/middleware/swaggerDocs/swaggerDocs.d.ts +6 -0
  330. package/dist/middleware/swaggerDocs/swaggerDocs.js +103 -0
  331. package/dist/middleware/swaggerDocs/swaggerDocs.js.map +1 -0
  332. package/dist/middleware/swaggerDocs/swaggerDocs.types.d.ts +37 -0
  333. package/dist/middleware/swaggerDocs/swaggerDocs.types.js +2 -0
  334. package/dist/middleware/swaggerDocs/swaggerDocs.types.js.map +1 -0
  335. package/dist/middleware/userResolver/index.d.ts +1 -0
  336. package/dist/middleware/userResolver/index.js +17 -0
  337. package/dist/middleware/userResolver/index.js.map +1 -0
  338. package/dist/middleware/userResolver/userResolver.d.ts +3 -0
  339. package/dist/middleware/userResolver/userResolver.js +41 -0
  340. package/dist/middleware/userResolver/userResolver.js.map +1 -0
  341. package/dist/middleware/validate/index.d.ts +1 -0
  342. package/dist/middleware/validate/index.js +17 -0
  343. package/dist/middleware/validate/index.js.map +1 -0
  344. package/dist/middleware/validate/validate.d.ts +4 -0
  345. package/dist/middleware/validate/validate.js +19 -0
  346. package/dist/middleware/validate/validate.js.map +1 -0
  347. package/dist/middleware/version/index.d.ts +1 -0
  348. package/dist/middleware/version/index.js +17 -0
  349. package/dist/middleware/version/index.js.map +1 -0
  350. package/dist/middleware/version/version.d.ts +6 -0
  351. package/dist/middleware/version/version.js +21 -0
  352. package/dist/middleware/version/version.js.map +1 -0
  353. package/dist/utils/checkEnvironment/index.d.ts +13 -0
  354. package/dist/utils/checkEnvironment/index.js +62 -0
  355. package/dist/utils/checkEnvironment/index.js.map +1 -0
  356. package/dist/utils/createHttpServer/createHttpServer.d.ts +5 -0
  357. package/dist/utils/createHttpServer/createHttpServer.js +30 -0
  358. package/dist/utils/createHttpServer/createHttpServer.js.map +1 -0
  359. package/dist/utils/createHttpServer/createHttpServer.validate.d.ts +4 -0
  360. package/dist/utils/createHttpServer/createHttpServer.validate.js +31 -0
  361. package/dist/utils/createHttpServer/createHttpServer.validate.js.map +1 -0
  362. package/dist/utils/createHttpServer/index.d.ts +1 -0
  363. package/dist/utils/createHttpServer/index.js +17 -0
  364. package/dist/utils/createHttpServer/index.js.map +1 -0
  365. package/dist/utils/createSortedObject/createSortedObject.d.ts +2 -0
  366. package/dist/utils/createSortedObject/createSortedObject.js +21 -0
  367. package/dist/utils/createSortedObject/createSortedObject.js.map +1 -0
  368. package/dist/utils/createSortedObject/index.d.ts +1 -0
  369. package/dist/utils/createSortedObject/index.js +17 -0
  370. package/dist/utils/createSortedObject/index.js.map +1 -0
  371. package/dist/utils/dbMigration/dbMigration.d.ts +17 -0
  372. package/dist/utils/dbMigration/dbMigration.js +207 -0
  373. package/dist/utils/dbMigration/dbMigration.js.map +1 -0
  374. package/dist/utils/dbMigration/dbMigration.types.d.ts +10 -0
  375. package/dist/utils/dbMigration/dbMigration.types.js +2 -0
  376. package/dist/utils/dbMigration/dbMigration.types.js.map +1 -0
  377. package/dist/utils/dbMigration/index.d.ts +2 -0
  378. package/dist/utils/dbMigration/index.js +28 -0
  379. package/dist/utils/dbMigration/index.js.map +1 -0
  380. package/dist/utils/dbMigration/migrateMetadataTable/index.d.ts +1 -0
  381. package/dist/utils/dbMigration/migrateMetadataTable/index.js +17 -0
  382. package/dist/utils/dbMigration/migrateMetadataTable/index.js.map +1 -0
  383. package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.d.ts +7 -0
  384. package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js +63 -0
  385. package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js.map +1 -0
  386. package/dist/utils/envAssert/envAssert.d.ts +21 -0
  387. package/dist/utils/envAssert/envAssert.js +30 -0
  388. package/dist/utils/envAssert/envAssert.js.map +1 -0
  389. package/dist/utils/envAssert/index.d.ts +1 -0
  390. package/dist/utils/envAssert/index.js +17 -0
  391. package/dist/utils/envAssert/index.js.map +1 -0
  392. package/dist/utils/envAssert/validators/hostList.d.ts +4 -0
  393. package/dist/utils/envAssert/validators/hostList.js +22 -0
  394. package/dist/utils/envAssert/validators/hostList.js.map +1 -0
  395. package/dist/utils/envAssert/validators/index.d.ts +5 -0
  396. package/dist/utils/envAssert/validators/index.js +61 -0
  397. package/dist/utils/envAssert/validators/index.js.map +1 -0
  398. package/dist/utils/envAssert/validators/ipList.d.ts +4 -0
  399. package/dist/utils/envAssert/validators/ipList.js +20 -0
  400. package/dist/utils/envAssert/validators/ipList.js.map +1 -0
  401. package/dist/utils/envAssert/validators/path.d.ts +4 -0
  402. package/dist/utils/envAssert/validators/path.js +19 -0
  403. package/dist/utils/envAssert/validators/path.js.map +1 -0
  404. package/dist/utils/envAssert/validators/string.d.ts +4 -0
  405. package/dist/utils/envAssert/validators/string.js +15 -0
  406. package/dist/utils/envAssert/validators/string.js.map +1 -0
  407. package/dist/utils/envAssert/validators/stringList.d.ts +5 -0
  408. package/dist/utils/envAssert/validators/stringList.js +19 -0
  409. package/dist/utils/envAssert/validators/stringList.js.map +1 -0
  410. package/dist/utils/filter/filter.d.ts +6 -0
  411. package/dist/utils/filter/filter.js +21 -0
  412. package/dist/utils/filter/filter.js.map +1 -0
  413. package/dist/utils/filter/index.d.ts +1 -0
  414. package/dist/utils/filter/index.js +17 -0
  415. package/dist/utils/filter/index.js.map +1 -0
  416. package/dist/utils/getDynamicLink/getDynamicLink.d.ts +3 -0
  417. package/dist/utils/getDynamicLink/getDynamicLink.js +28 -0
  418. package/dist/utils/getDynamicLink/getDynamicLink.js.map +1 -0
  419. package/dist/utils/getDynamicLink/getDynamicLink.types.d.ts +10 -0
  420. package/dist/utils/getDynamicLink/getDynamicLink.types.js +2 -0
  421. package/dist/utils/getDynamicLink/getDynamicLink.types.js.map +1 -0
  422. package/dist/utils/getDynamicLink/getDynamicLink.validate.d.ts +2 -0
  423. package/dist/utils/getDynamicLink/getDynamicLink.validate.js +14 -0
  424. package/dist/utils/getDynamicLink/getDynamicLink.validate.js.map +1 -0
  425. package/dist/utils/getDynamicLink/index.d.ts +2 -0
  426. package/dist/utils/getDynamicLink/index.js +28 -0
  427. package/dist/utils/getDynamicLink/index.js.map +1 -0
  428. package/dist/utils/hmac/checkEnv/checkEnv.d.ts +4 -0
  429. package/dist/utils/hmac/checkEnv/checkEnv.js +17 -0
  430. package/dist/utils/hmac/checkEnv/checkEnv.js.map +1 -0
  431. package/dist/utils/hmac/checkEnv/index.d.ts +1 -0
  432. package/dist/utils/hmac/checkEnv/index.js +17 -0
  433. package/dist/utils/hmac/checkEnv/index.js.map +1 -0
  434. package/dist/utils/hmac/createHmac/createHmac.d.ts +3 -0
  435. package/dist/utils/hmac/createHmac/createHmac.js +33 -0
  436. package/dist/utils/hmac/createHmac/createHmac.js.map +1 -0
  437. package/dist/utils/hmac/createHmac/index.d.ts +1 -0
  438. package/dist/utils/hmac/createHmac/index.js +17 -0
  439. package/dist/utils/hmac/createHmac/index.js.map +1 -0
  440. package/dist/utils/hmac/index.d.ts +4 -0
  441. package/dist/utils/hmac/index.js +50 -0
  442. package/dist/utils/hmac/index.js.map +1 -0
  443. package/dist/utils/hmac/index.types.d.ts +12 -0
  444. package/dist/utils/hmac/index.types.js +2 -0
  445. package/dist/utils/hmac/index.types.js.map +1 -0
  446. package/dist/utils/hmac/signPayload/index.d.ts +1 -0
  447. package/dist/utils/hmac/signPayload/index.js +17 -0
  448. package/dist/utils/hmac/signPayload/index.js.map +1 -0
  449. package/dist/utils/hmac/signPayload/signPayload.d.ts +6 -0
  450. package/dist/utils/hmac/signPayload/signPayload.js +18 -0
  451. package/dist/utils/hmac/signPayload/signPayload.js.map +1 -0
  452. package/dist/utils/hmac/verifySignature/index.d.ts +1 -0
  453. package/dist/utils/hmac/verifySignature/index.js +17 -0
  454. package/dist/utils/hmac/verifySignature/index.js.map +1 -0
  455. package/dist/utils/hmac/verifySignature/verifySignature.d.ts +3 -0
  456. package/dist/utils/hmac/verifySignature/verifySignature.js +23 -0
  457. package/dist/utils/hmac/verifySignature/verifySignature.js.map +1 -0
  458. package/dist/utils/index.d.ts +17 -0
  459. package/dist/utils/index.js +193 -0
  460. package/dist/utils/index.js.map +1 -0
  461. package/dist/utils/jwt/index.d.ts +2 -0
  462. package/dist/utils/jwt/index.js +28 -0
  463. package/dist/utils/jwt/index.js.map +1 -0
  464. package/dist/utils/jwt/jwt.d.ts +12 -0
  465. package/dist/utils/jwt/jwt.js +195 -0
  466. package/dist/utils/jwt/jwt.js.map +1 -0
  467. package/dist/utils/jwt/jwt.types.d.ts +20 -0
  468. package/dist/utils/jwt/jwt.types.js +2 -0
  469. package/dist/utils/jwt/jwt.types.js.map +1 -0
  470. package/dist/utils/report/index.d.ts +3 -0
  471. package/dist/utils/report/index.js +39 -0
  472. package/dist/utils/report/index.js.map +1 -0
  473. package/dist/utils/report/output.d.ts +4 -0
  474. package/dist/utils/report/output.js +49 -0
  475. package/dist/utils/report/output.js.map +1 -0
  476. package/dist/utils/report/output.types.d.ts +65 -0
  477. package/dist/utils/report/output.types.js +2 -0
  478. package/dist/utils/report/output.types.js.map +1 -0
  479. package/dist/utils/report/report.d.ts +18 -0
  480. package/dist/utils/report/report.js +119 -0
  481. package/dist/utils/report/report.js.map +1 -0
  482. package/dist/utils/report/report.types.d.ts +11 -0
  483. package/dist/utils/report/report.types.js +2 -0
  484. package/dist/utils/report/report.types.js.map +1 -0
  485. package/dist/utils/request/index.d.ts +1 -0
  486. package/dist/utils/request/index.js +17 -0
  487. package/dist/utils/request/index.js.map +1 -0
  488. package/dist/utils/request/request.d.ts +3 -0
  489. package/dist/utils/request/request.js +42 -0
  490. package/dist/utils/request/request.js.map +1 -0
  491. package/dist/utils/semverCompare/index.d.ts +1 -0
  492. package/dist/utils/semverCompare/index.js +17 -0
  493. package/dist/utils/semverCompare/index.js.map +1 -0
  494. package/dist/utils/semverCompare/semverCompare.d.ts +7 -0
  495. package/dist/utils/semverCompare/semverCompare.js +65 -0
  496. package/dist/utils/semverCompare/semverCompare.js.map +1 -0
  497. package/dist/utils/sendEmail/index.d.ts +1 -0
  498. package/dist/utils/sendEmail/index.js +17 -0
  499. package/dist/utils/sendEmail/index.js.map +1 -0
  500. package/dist/utils/sendEmail/sendEmail.d.ts +11 -0
  501. package/dist/utils/sendEmail/sendEmail.js +32 -0
  502. package/dist/utils/sendEmail/sendEmail.js.map +1 -0
  503. package/dist/utils/sendEmail/sendEmail.types.d.ts +7 -0
  504. package/dist/utils/sendEmail/sendEmail.types.js +2 -0
  505. package/dist/utils/sendEmail/sendEmail.types.js.map +1 -0
  506. package/dist/utils/sendPush/index.d.ts +2 -0
  507. package/dist/utils/sendPush/index.js +28 -0
  508. package/dist/utils/sendPush/index.js.map +1 -0
  509. package/dist/utils/sendPush/sendPush.d.ts +8 -0
  510. package/dist/utils/sendPush/sendPush.js +25 -0
  511. package/dist/utils/sendPush/sendPush.js.map +1 -0
  512. package/dist/utils/sendPush/sendPush.types.d.ts +25 -0
  513. package/dist/utils/sendPush/sendPush.types.js +2 -0
  514. package/dist/utils/sendPush/sendPush.types.js.map +1 -0
  515. package/dist/utils/tlsConfig/index.d.ts +2 -0
  516. package/dist/utils/tlsConfig/index.js +28 -0
  517. package/dist/utils/tlsConfig/index.js.map +1 -0
  518. package/dist/utils/tlsConfig/tlsConfig.d.ts +8 -0
  519. package/dist/utils/tlsConfig/tlsConfig.js +44 -0
  520. package/dist/utils/tlsConfig/tlsConfig.js.map +1 -0
  521. package/dist/utils/tlsConfig/tlsConfig.types.d.ts +11 -0
  522. package/dist/utils/tlsConfig/tlsConfig.types.js +2 -0
  523. package/dist/utils/tlsConfig/tlsConfig.types.js.map +1 -0
  524. package/dist/utils/tlsConfig/tlsConfig.validate.d.ts +4 -0
  525. package/dist/utils/tlsConfig/tlsConfig.validate.js +48 -0
  526. package/dist/utils/tlsConfig/tlsConfig.validate.js.map +1 -0
  527. package/dist/utils/tlsRequest/index.d.ts +1 -0
  528. package/dist/utils/tlsRequest/index.js +17 -0
  529. package/dist/utils/tlsRequest/index.js.map +1 -0
  530. package/dist/utils/tlsRequest/tlsRequest.d.ts +3 -0
  531. package/dist/utils/tlsRequest/tlsRequest.js +18 -0
  532. package/dist/utils/tlsRequest/tlsRequest.js.map +1 -0
  533. package/dist/utils/trimPathSlash/index.d.ts +1 -0
  534. package/dist/utils/trimPathSlash/index.js +17 -0
  535. package/dist/utils/trimPathSlash/index.js.map +1 -0
  536. package/dist/utils/trimPathSlash/trimPathSlash.d.ts +6 -0
  537. package/dist/utils/trimPathSlash/trimPathSlash.js +15 -0
  538. package/dist/utils/trimPathSlash/trimPathSlash.js.map +1 -0
  539. package/eslint.config.mjs +11 -0
  540. package/package.json +157 -0
  541. package/src/const/DebeziumEvent.ts +6 -0
  542. package/src/const/LogSeverity.ts +7 -0
  543. package/src/const/index.ts +5 -0
  544. package/src/const/metrics.ts +6 -0
  545. package/src/const/mime.ts +37 -0
  546. package/src/const/tokenIssuer.ts +9 -0
  547. package/src/db/migrations/20241030121500-create-sequelize-meta-table.ts +29 -0
  548. package/src/db/models/SequelizeMeta.ts +16 -0
  549. package/src/db/models/index.ts +2 -0
  550. package/src/entities/ElasticSearch/ElasticSearch.ts +103 -0
  551. package/src/entities/ElasticSearch/ElasticSearch.types.ts +7 -0
  552. package/src/entities/ElasticSearch/index.ts +2 -0
  553. package/src/entities/Endpoint/Endpoint.test.ts +337 -0
  554. package/src/entities/Endpoint/Endpoint.ts +202 -0
  555. package/src/entities/Endpoint/Endpoint.types.ts +205 -0
  556. package/src/entities/Endpoint/index.ts +2 -0
  557. package/src/entities/EngineError/EngineError.ts +28 -0
  558. package/src/entities/EngineError/EngineError.types.ts +15 -0
  559. package/src/entities/EngineError/index.ts +2 -0
  560. package/src/entities/KeySet/KeySet.test.ts +126 -0
  561. package/src/entities/KeySet/KeySet.ts +172 -0
  562. package/src/entities/KeySet/KeySet.types.ts +28 -0
  563. package/src/entities/KeySet/index.ts +2 -0
  564. package/src/entities/LifecycleController/LifecycleController.test.ts +48 -0
  565. package/src/entities/LifecycleController/LifecycleController.ts +24 -0
  566. package/src/entities/LifecycleController/LifecycleController.types.ts +5 -0
  567. package/src/entities/LifecycleController/index.ts +2 -0
  568. package/src/entities/Localizator/Localizator.ts +139 -0
  569. package/src/entities/Localizator/Localizator.types.ts +52 -0
  570. package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.test.ts +165 -0
  571. package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.ts +58 -0
  572. package/src/entities/Localizator/guessNamingConvention/index.ts +1 -0
  573. package/src/entities/Localizator/index.ts +2 -0
  574. package/src/entities/MessageHandler/MessageHandler.test.ts +130 -0
  575. package/src/entities/MessageHandler/MessageHandler.ts +72 -0
  576. package/src/entities/MessageHandler/MessageHandler.types.ts +15 -0
  577. package/src/entities/MessageHandler/index.ts +2 -0
  578. package/src/entities/PubSub/PubSub.test.ts +297 -0
  579. package/src/entities/PubSub/PubSub.ts +202 -0
  580. package/src/entities/PubSub/PubSub.types.ts +76 -0
  581. package/src/entities/PubSub/handleMessage/handleMessage.test.ts +102 -0
  582. package/src/entities/PubSub/handleMessage/handleMessage.ts +65 -0
  583. package/src/entities/PubSub/handleMessage/index.ts +1 -0
  584. package/src/entities/PubSub/index.ts +2 -0
  585. package/src/entities/PushNotification/PushNotification.test.ts +35 -0
  586. package/src/entities/PushNotification/PushNotification.ts +44 -0
  587. package/src/entities/PushNotification/PushNotification.types.ts +25 -0
  588. package/src/entities/PushNotification/index.ts +2 -0
  589. package/src/entities/Redis/Redis.ts +71 -0
  590. package/src/entities/Redis/Redis.types.ts +19 -0
  591. package/src/entities/Redis/Redis.validate.ts +17 -0
  592. package/src/entities/Redis/index.ts +2 -0
  593. package/src/entities/Sequelize/Sequelize.config.ts +29 -0
  594. package/src/entities/Sequelize/Sequelize.test.ts +21 -0
  595. package/src/entities/Sequelize/Sequelize.ts +75 -0
  596. package/src/entities/Sequelize/Sequelize.types.ts +10 -0
  597. package/src/entities/Sequelize/Sequelize.validate.ts +15 -0
  598. package/src/entities/Sequelize/index.ts +2 -0
  599. package/src/entities/Server/Server.const.ts +56 -0
  600. package/src/entities/Server/Server.test.ts +272 -0
  601. package/src/entities/Server/Server.ts +445 -0
  602. package/src/entities/Server/Server.types.ts +88 -0
  603. package/src/entities/Server/index.ts +2 -0
  604. package/src/entities/SocketClient/SocketClient.test.ts +392 -0
  605. package/src/entities/SocketClient/SocketClient.ts +401 -0
  606. package/src/entities/SocketClient/SocketClient.types.ts +62 -0
  607. package/src/entities/SocketClient/index.ts +2 -0
  608. package/src/entities/SocketClient/parseMessage/index.ts +1 -0
  609. package/src/entities/SocketClient/parseMessage/parseMessage.test.ts +20 -0
  610. package/src/entities/SocketClient/parseMessage/parseMessage.ts +26 -0
  611. package/src/entities/Storage/Storage.test.ts +58 -0
  612. package/src/entities/Storage/Storage.ts +219 -0
  613. package/src/entities/Storage/Storage.types.ts +57 -0
  614. package/src/entities/Storage/index.ts +2 -0
  615. package/src/entities/ValidationError/ValidationError.ts +34 -0
  616. package/src/entities/ValidationError/index.ts +1 -0
  617. package/src/entities/WebError/WebError.test.ts +18 -0
  618. package/src/entities/WebError/WebError.ts +23 -0
  619. package/src/entities/WebError/WebError.types.ts +9 -0
  620. package/src/entities/WebError/index.ts +2 -0
  621. package/src/entities/index.ts +16 -0
  622. package/src/index.ts +4 -0
  623. package/src/metrics/debug.ts +10 -0
  624. package/src/metrics/index.ts +2 -0
  625. package/src/metrics/request.ts +17 -0
  626. package/src/middleware/authAdmin/authAdmin.test.ts +199 -0
  627. package/src/middleware/authAdmin/authAdmin.ts +114 -0
  628. package/src/middleware/authAdmin/authAdmin.types.ts +19 -0
  629. package/src/middleware/authAdmin/index.ts +2 -0
  630. package/src/middleware/authHmac/authHmac.test.ts +86 -0
  631. package/src/middleware/authHmac/authHmac.ts +56 -0
  632. package/src/middleware/authHmac/authHmac.types.ts +7 -0
  633. package/src/middleware/authHmac/index.ts +2 -0
  634. package/src/middleware/authJwt/authJwt.test.ts +54 -0
  635. package/src/middleware/authJwt/authJwt.ts +55 -0
  636. package/src/middleware/authJwt/authJwt.types.ts +25 -0
  637. package/src/middleware/authJwt/index.ts +2 -0
  638. package/src/middleware/authStatic/authStatic.test.ts +36 -0
  639. package/src/middleware/authStatic/authStatic.ts +45 -0
  640. package/src/middleware/authStatic/index.ts +1 -0
  641. package/src/middleware/authTls/authTls.test.ts +138 -0
  642. package/src/middleware/authTls/authTls.ts +106 -0
  643. package/src/middleware/authTls/authTls.types.ts +13 -0
  644. package/src/middleware/authTls/index.ts +2 -0
  645. package/src/middleware/error/error.test.ts +60 -0
  646. package/src/middleware/error/error.ts +25 -0
  647. package/src/middleware/error/index.ts +1 -0
  648. package/src/middleware/fileUploader/compressAvatar/compressAvatar.ts +25 -0
  649. package/src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts +12 -0
  650. package/src/middleware/fileUploader/compressAvatar/index.ts +2 -0
  651. package/src/middleware/fileUploader/fileUploader.test.ts +310 -0
  652. package/src/middleware/fileUploader/fileUploader.ts +303 -0
  653. package/src/middleware/fileUploader/fileUploader.types.ts +52 -0
  654. package/src/middleware/fileUploader/index.ts +2 -0
  655. package/src/middleware/fileUploader/isMultiPart/index.ts +1 -0
  656. package/src/middleware/fileUploader/isMultiPart/isMultipart.ts +9 -0
  657. package/src/middleware/fileUploader/validate/index.ts +1 -0
  658. package/src/middleware/fileUploader/validate/validate.ts +27 -0
  659. package/src/middleware/fourOhFour/fourOhFour.test.ts +14 -0
  660. package/src/middleware/fourOhFour/fourOhFour.ts +13 -0
  661. package/src/middleware/fourOhFour/index.ts +1 -0
  662. package/src/middleware/healthCheck/healthCheck.test.ts +12 -0
  663. package/src/middleware/healthCheck/healthCheck.ts +14 -0
  664. package/src/middleware/healthCheck/index.ts +1 -0
  665. package/src/middleware/index.ts +15 -0
  666. package/src/middleware/metrics/index.ts +1 -0
  667. package/src/middleware/metrics/metrics.test.ts +46 -0
  668. package/src/middleware/metrics/metrics.ts +24 -0
  669. package/src/middleware/requestMetrics/index.ts +1 -0
  670. package/src/middleware/requestMetrics/requestMetrics.test.ts +77 -0
  671. package/src/middleware/requestMetrics/requestMetrics.ts +20 -0
  672. package/src/middleware/swaggerDocs/index.ts +2 -0
  673. package/src/middleware/swaggerDocs/swaggerDocs.ts +114 -0
  674. package/src/middleware/swaggerDocs/swaggerDocs.types.ts +41 -0
  675. package/src/middleware/userResolver/index.ts +1 -0
  676. package/src/middleware/userResolver/userResolver.test.ts +35 -0
  677. package/src/middleware/userResolver/userResolver.ts +36 -0
  678. package/src/middleware/validate/index.ts +1 -0
  679. package/src/middleware/validate/validate.test.ts +43 -0
  680. package/src/middleware/validate/validate.ts +25 -0
  681. package/src/middleware/version/index.ts +1 -0
  682. package/src/middleware/version/version.test.ts +23 -0
  683. package/src/middleware/version/version.ts +12 -0
  684. package/src/utils/checkEnvironment/index.ts +49 -0
  685. package/src/utils/createHttpServer/createHttpServer.test.ts +24 -0
  686. package/src/utils/createHttpServer/createHttpServer.ts +34 -0
  687. package/src/utils/createHttpServer/createHttpServer.validate.ts +17 -0
  688. package/src/utils/createHttpServer/index.ts +1 -0
  689. package/src/utils/createSortedObject/createSortedObject.ts +20 -0
  690. package/src/utils/createSortedObject/createSortedObjet.test.ts +47 -0
  691. package/src/utils/createSortedObject/index.ts +1 -0
  692. package/src/utils/dbMigration/dbMigration.test.ts +209 -0
  693. package/src/utils/dbMigration/dbMigration.ts +196 -0
  694. package/src/utils/dbMigration/dbMigration.types.ts +11 -0
  695. package/src/utils/dbMigration/index.ts +2 -0
  696. package/src/utils/dbMigration/migrateMetadataTable/index.ts +1 -0
  697. package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.test.ts +59 -0
  698. package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts +70 -0
  699. package/src/utils/envAssert/envAssert.ts +31 -0
  700. package/src/utils/envAssert/index.ts +1 -0
  701. package/src/utils/envAssert/validators/hostList.ts +17 -0
  702. package/src/utils/envAssert/validators/index.ts +5 -0
  703. package/src/utils/envAssert/validators/ipList.ts +13 -0
  704. package/src/utils/envAssert/validators/path.ts +13 -0
  705. package/src/utils/envAssert/validators/string.ts +9 -0
  706. package/src/utils/envAssert/validators/stringList.ts +13 -0
  707. package/src/utils/filter/filter.ts +17 -0
  708. package/src/utils/filter/index.ts +1 -0
  709. package/src/utils/getDynamicLink/getDynamicLink.test.ts +51 -0
  710. package/src/utils/getDynamicLink/getDynamicLink.ts +28 -0
  711. package/src/utils/getDynamicLink/getDynamicLink.types.ts +11 -0
  712. package/src/utils/getDynamicLink/getDynamicLink.validate.ts +6 -0
  713. package/src/utils/getDynamicLink/index.ts +2 -0
  714. package/src/utils/hmac/checkEnv/checkEnv.test.ts +18 -0
  715. package/src/utils/hmac/checkEnv/checkEnv.ts +9 -0
  716. package/src/utils/hmac/checkEnv/index.ts +1 -0
  717. package/src/utils/hmac/createHmac/createHmac.ts +33 -0
  718. package/src/utils/hmac/createHmac/index.ts +1 -0
  719. package/src/utils/hmac/index.ts +4 -0
  720. package/src/utils/hmac/index.types.ts +13 -0
  721. package/src/utils/hmac/signPayload/index.ts +1 -0
  722. package/src/utils/hmac/signPayload/signPayload.ts +16 -0
  723. package/src/utils/hmac/verifySignature/index.ts +1 -0
  724. package/src/utils/hmac/verifySignature/verifySignature.ts +24 -0
  725. package/src/utils/index.ts +26 -0
  726. package/src/utils/jwt/index.ts +2 -0
  727. package/src/utils/jwt/jwt.test.ts +41 -0
  728. package/src/utils/jwt/jwt.ts +204 -0
  729. package/src/utils/jwt/jwt.types.ts +21 -0
  730. package/src/utils/report/index.ts +3 -0
  731. package/src/utils/report/output.ts +45 -0
  732. package/src/utils/report/output.types.ts +70 -0
  733. package/src/utils/report/report.test.ts +133 -0
  734. package/src/utils/report/report.ts +134 -0
  735. package/src/utils/report/report.types.ts +13 -0
  736. package/src/utils/request/index.ts +1 -0
  737. package/src/utils/request/request.test.ts +26 -0
  738. package/src/utils/request/request.ts +48 -0
  739. package/src/utils/semverCompare/index.ts +1 -0
  740. package/src/utils/semverCompare/semverCompare.test.ts +49 -0
  741. package/src/utils/semverCompare/semverCompare.ts +60 -0
  742. package/src/utils/sendEmail/index.ts +1 -0
  743. package/src/utils/sendEmail/sendEmail.ts +27 -0
  744. package/src/utils/sendEmail/sendEmail.types.ts +7 -0
  745. package/src/utils/sendPush/index.ts +2 -0
  746. package/src/utils/sendPush/sendPush.ts +20 -0
  747. package/src/utils/sendPush/sendPush.types.ts +25 -0
  748. package/src/utils/tlsConfig/index.ts +2 -0
  749. package/src/utils/tlsConfig/tlsConfig.test.ts +32 -0
  750. package/src/utils/tlsConfig/tlsConfig.ts +47 -0
  751. package/src/utils/tlsConfig/tlsConfig.types.ts +11 -0
  752. package/src/utils/tlsConfig/tlsConfig.validate.ts +25 -0
  753. package/src/utils/tlsRequest/index.ts +1 -0
  754. package/src/utils/tlsRequest/tlsRequest.test.ts +63 -0
  755. package/src/utils/tlsRequest/tlsRequest.ts +12 -0
  756. package/src/utils/trimPathSlash/index.ts +1 -0
  757. package/src/utils/trimPathSlash/trimPathSlash.test.ts +26 -0
  758. package/src/utils/trimPathSlash/trimPathSlash.ts +8 -0
  759. package/test/env.ts +56 -0
  760. package/test/factory/index.ts +8 -0
  761. package/test/factory/sequelizeMeta.ts +12 -0
  762. package/test/hooks.ts +37 -0
  763. package/test/index.ts +3 -0
  764. package/test/stub/index.ts +3 -0
  765. package/test/stub/stubLocales.ts +68 -0
  766. package/test/stub/stubPubSub.ts +7 -0
  767. package/test/stub/stubStorage.ts +77 -0
  768. package/test/stub/stubStorage.types.ts +11 -0
  769. package/test/utils/app.ts +31 -0
  770. package/test/utils/index.ts +1 -0
  771. package/tsconfig.build.json +5 -0
  772. package/tsconfig.json +32 -0
package/README.md ADDED
@@ -0,0 +1,960 @@
1
+ # Node Server Engine
2
+
3
+ Framework used to develop Node backend services. This package ships with a lot of features to standardize the creation of services, letting you focus on the business logic.
4
+
5
+ - [Node Server Engine](#Node-server-engine)
6
+ - [Install](#install)
7
+ - [Entities](#entities)
8
+ - [Server](#server)
9
+ - [Server Configuration](#server-configuration)
10
+ - [Endpoint](#endpoint)
11
+ - [Endpoint Configuration](#endpoint-configuration)
12
+ - [Methods](#methods)
13
+ - [Authentication](#authentication)
14
+ - [File Upload](#file-upload)
15
+ - [Socket Client](#socket-client)
16
+ - [Socket Client Options](#socket-client-options)
17
+ - [Properties](#properties)
18
+ - [Message Handler](#message-handler)
19
+ - [Redis](#redis)
20
+ - [Sequelize](#sequelize)
21
+ - [Pub/Sub](#pubsub)
22
+ - [MediaProcessor](#mediaprocessor)
23
+ - [PushNotification](#pushnotification)
24
+ - [Localizator](#localizator)
25
+ - [ElasticSearch](#elasticsearch)
26
+ - [Translation Manager](#translation-manager)
27
+ - [Error Reporting](#error-reporting)
28
+ - [Common options](#common-options)
29
+ - [Severity](#severity)
30
+ - [Log Levels](#log-levels)
31
+ - [EngineError](#engineerror)
32
+ - [WebError](#weberror)
33
+ - [Middlewares](#middlewares)
34
+ - [Swagger Docs](#swagger-docs)
35
+ - [Structuring Documentation](#structuring-documentation)
36
+ - [Schemas and Responses](#schemas-and-responses)
37
+ - [User Resolver](#user-resolver)
38
+ - [Utilities](#utilities)
39
+ - [Request](#request)
40
+ - [TLS Request](#tls-request)
41
+ - [TLS Config](#tls-config)
42
+ - [Send Push Notification](#send-push-notification)
43
+ - [Send Email](#send-email)
44
+ - [Filter](#filter)
45
+ - [Database Migration](#database-migration)
46
+ - [Environment Variables Verification](#environment-variables-verification)
47
+ - [Assertions Available](#assertions-available)
48
+ - [Wait](#wait)
49
+
50
+ ## Install
51
+
52
+ To start a new service, it is **highly recomended** that you clone it from [our template](https://github.com/prakashmahendran/node-server-template). It will already include all the necessary tools and boilerplate.
53
+
54
+ If you need to install it manually:
55
+
56
+ ```bash
57
+ npm i node-server-engine
58
+ ```
59
+
60
+ ## Entities
61
+
62
+ ### Server
63
+
64
+ The server class encapsulates all of the express boilerplate. Instantiate one per service and initialize it to get started.
65
+
66
+ ```javascript
67
+ import { Server } from 'node-server-engine';
68
+ const server = new Server(config);
69
+ server.init();
70
+ ```
71
+
72
+ #### Server Configuration
73
+
74
+ <!-- markdownlint-disable MD033 -->
75
+
76
+ | Property | Type | Behavior | Default |
77
+ | ----------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
78
+ | port | Number | Port to listen to | `process.env.PORT` |
79
+ | endpoints | Array\<[Endpoint](#endpoint)> | List of endpoints that should be served. | [] |
80
+ | globalMiddleware | Array\<Function> <br> Array\<{middleware: Function, path: String}> | List of middlewares that should be executed for each endpoint's logic. If it is given as an object with a path, it will only be applied to requests with this base path. | [] |
81
+ | errorMiddleware | Array\<Function> <br> Array\<{middleware: Function, path: String}> | List of middlewares that should be executed after each endpoint's logic. If it is given as an object with a path, it will only be applied to requests with this base path. | [] |
82
+ | initCallbacks | Array\<Function> | List of functions that are called on server start |
83
+ | [] |
84
+ | syncCallbacks | boolean | Forces the init callbacks to run one after the other and not in parallel |
85
+ | false |
86
+ | cron | Array\<Object> | List of cronjob that are called on server start | [] |
87
+ | shutdownCallbacks | Array\<Function> | List of functions that are called on server shutdown | [] |
88
+ | checkEnvironment | Object | [Schema against which verify the environment variables](#environment-variables-verification), will cause server termination if the environment variables are not properly set. | {} |
89
+ | webSocket.server | Object | Settings to create a WebSocket server. See the [ws package documentation](https://github.com/websockets/ws/blob/master/doc/ws.md#new-websocketserveroptions-callback) for details. | |
90
+ | webSocket.client | Object | Settings passed down to [SocketClient](#socket-client) when a new socket connection is established. | |
91
+
92
+ <!-- markdownlint-enable MD033 -->
93
+
94
+ ---
95
+
96
+ ### Endpoint
97
+
98
+ Endpoint encapsulates the logic of a single endpoint in a standard way.
99
+
100
+ The main function of the endpoint is called the **handler**. This function should only handle pure business logic for a given endpoint.
101
+
102
+ An endpoint usually has a **validator**. A validator is a schema that will be compared to the incoming request. The request will be denied if it contains illegal or malformed arguments. For more detail see the documentation of the underlying package [express-validator](https://express-validator.github.io/docs/schema-validation.html).
103
+
104
+ ```javascript
105
+ import { Endpoint, EndpointMethod } from 'node-server-engine';
106
+
107
+ // A basic handler that returns an HTTP status code of 200 to the client
108
+ function handler(req, res) {
109
+ res.sendStatus(200);
110
+ }
111
+
112
+ // The request must contain `id` as a query string and it must be a UUID V4
113
+ const validator = {
114
+ id: {
115
+ in: 'query',
116
+ isUUID: {
117
+ options: 4
118
+ }
119
+ }
120
+ };
121
+
122
+ // This endpoint can be passed to the Server
123
+ new Endpoint({
124
+ path: '/demo',
125
+ method: EndpointMethod.GET,
126
+ handler,
127
+ validator
128
+ });
129
+ ```
130
+
131
+ #### Endpoint Configuration
132
+
133
+ `new Endpoint(config)`
134
+
135
+ | Property | Type | Behavior | Default |
136
+ | --------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
137
+ | path | String | Path to which the endpoint should be served | **required** |
138
+ | method | [Method](#methods) | Method to which the endpoint should be served | **required** |
139
+ | handler | Function | Endpoint handler | **required** |
140
+ | validator | Object | Schema to validate against the request. [See documentation](https://express-validator.github.io/docs/schema-validation.html) for more details. | |
141
+ | authType | [AuthType](#authentication) | Authentication to use for this endpoint | AuthType.NONE |
142
+ | authParams | Object | Options specific to the [authentication methods](#authentication) | {} |
143
+ | files | Array\<Object> | Configuration to upload files. See the [specific documentation](#file-upload). | {} |
144
+ | middleware | Array\<Function> | List of middlewares to run before the handler. | [] |
145
+ | errorMiddleware | Array\<Function> | List of middlewares to run after the handler | [] |
146
+
147
+ ```javascript
148
+ const addNodeEndpoint = new Endpoint({
149
+ path: '/note',
150
+ method: EndpointMethod.POST,
151
+ handler: (req, res, next) => res.json(addNote(req.body)),
152
+ authType: EndpointAuthType.AUTH_JWT,
153
+ middleware: [migrateNoteToVersion2],
154
+ errorMiddleware: [addNoteErrorMiddleware],
155
+ validator: {
156
+ id: {
157
+ in: 'body',
158
+ isUUID: true
159
+ },
160
+ content: {
161
+ in: 'body',
162
+ isLength: {
163
+ errorMessage: 'content to long',
164
+ options: {
165
+ max: 150
166
+ }
167
+ }
168
+ }
169
+ }
170
+ });
171
+ ```
172
+
173
+ #### Methods
174
+
175
+ The following HTTP methods are supported
176
+
177
+ - Method.GET
178
+ - Method.POST
179
+ - Method.PUT
180
+ - Method.PATCH
181
+ - Method.DELETE
182
+ - Method.ALL - _respond to all requests on a path_
183
+
184
+ #### Authentication
185
+
186
+ Endpoints can take an authType and authParam in their configuration to determine their authentication behavior. The following table summarizes their usage.
187
+
188
+ The server engine exposes an enumeration for auth types.
189
+ `import {AuthType} from 'node-server-engine';`
190
+
191
+ <!-- markdownlint-disable MD033 -->
192
+
193
+ | AuthType | Description | AuthParams |
194
+ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
195
+ | AuthType.NONE | No authentication. All requests are handled | |
196
+ | AuthType.JWT | A valid JSON Web Token is required as Bearer token. To be valid it must be properly signed by auth0, and its payload must match with what is set as environment variables.<br>The user's ID is added to `req.user`. | |
197
+ | AuthType.TLS | Authenticate through mutual TLS. CA and an optional list of white listed host names should be set in the environment variables. | **whitelist** [Array<String>]: List of certificate Common Name or Alt Name that are permitted to make requests to this endpoint. |
198
+ | AuthType.HMAC | Authenticate with a signature in the payload.<br>**This authentication is deprecated and should be avoided** | **secret** [String]: Overrides the secret used for signatures set in environment variables<br>**isGithub** [Boolean]: The request is a Github webhook and therefore uses their signature system and not the default one. |
199
+ | AuthType.STATIC | A valid shared Bearer token is required. Shared token is stored in env variable (STATIC_TOKEN) | |
200
+ | AuthType.ADMIN | A valid JSON Web Token is required as Bearer token. To be valid it must be properly signed by admin api, and its payload must match with what is set as environment variables.<br>The user's email and permission is added to `req.user`. | **permission** [String]: Endpoint permission required for admin user |
201
+
202
+ <!-- markdownlint-enable MD033 -->
203
+
204
+ #### File Upload
205
+
206
+ An endpoint can upload a file to a cloud storage and pass down its url to the handler.
207
+
208
+ The request must be made as `multipart/form-data`.
209
+
210
+ The file's data will be available at `req.files`.
211
+
212
+ The following settings can be used on each object the Endpoint's `options.files`.
213
+
214
+ | Property | Type | Description | Default |
215
+ | ------------------- | -------------- | ------------------------------------------------------------------------ | ------------ |
216
+ | key | string | Form key as which the file should be fetched | **required** |
217
+ | path | string | Base path of the directory where the file should be stored in the bucket | `/` |
218
+ | bucket | string | Name of the bucket in which the file should be stored | **required** |
219
+ | maxSize | string | Maximum file size in a human readable format (ex: 5MB) | **required** |
220
+ | mimeTypes | Array\<string> | A list of accepted MIME Types | [] |
221
+ | required | boolean | Will fail the request and not store the files if this one is missing | false |
222
+ | noExtension | boolean | Store the file with no extension | false |
223
+ | image | Object | Image manipulation to perform on the uploaded file | |
224
+ | image.resize.height | number | Resize the image to fit a specific height | |
225
+ | image.resize.width | number | Resize the image to fit a specific width | |
226
+ | image.quality | number | JPEG quality factor to use for export | |
227
+
228
+ ---
229
+
230
+ ### Socket Client
231
+
232
+ The socket server start if the [Server](#server)'s webSocket option is not undefined.
233
+
234
+ Each time a new socket connection is established, a new instance of `SocketClient` is created.
235
+
236
+ #### Socket Client Options
237
+
238
+ Options can be set for SocketClient when setting up a Server instance.
239
+
240
+ | Parameter | Type | Description | Default |
241
+ | ----------------- | ------------------------------------------ | ----------------------------------------------------------------------- | ------------ |
242
+ | handlers | Array\<[MessageHandler](#message-handler)> | A list of message handlers to use | **required** |
243
+ | authCallbacks | Array\<function> | Callbacks called when a client successfully authenticates on the socket | [] |
244
+ | initCallbacks | Array\<function> | Callbacks called when the socket client is created | [] |
245
+ | shutdownCallbacks | Array\<function> | Callbacks called when the socket client is destroyed | [] |
246
+
247
+ #### Properties
248
+
249
+ | Property | Type | Description |
250
+ | ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
251
+ | id | String | A unique identifier for the connection |
252
+ | ws | Object | The socket being used. Instance of [WebSocket](https://github.com/websockets/ws/blob/master/doc/ws.md#class-websocket) |
253
+ | authenticated | Boolean | Flag indicating that the current user is authenticated |
254
+ | userId | String | Id of the current user **(available when authenticated)** |
255
+
256
+ ---
257
+
258
+ ### Message Handler
259
+
260
+ Message handler are similar to [Endpoint](#endpoint), but in a WebSocket context. They define how incoming messages should be handled.
261
+
262
+ ```javascript
263
+ import { MessageHandler, Server } from 'node-server-engine';
264
+
265
+ function handler(payload, client) {
266
+ // payload is the message payload in a standard message.
267
+ // client is an instance of SocketClient
268
+ }
269
+
270
+ const messageHandler = new MessageHandler(type, handler, options);
271
+
272
+ new Server({
273
+ webSocket: { client: { handlers: [messageHandler] } }
274
+ });
275
+ ```
276
+
277
+ | Argument | Type | Description | Default |
278
+ | --------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------- | ------------ |
279
+ | type | String | The message type that should be handled | **required** |
280
+ | handler | Function | A function that will run for every message of this type | **required** |
281
+ | options.authenticated | A flag indicating that this kind of message handling require an authenticated client | `true` |
282
+
283
+ ---
284
+
285
+ ### Redis
286
+
287
+ The server engine exposes a Redis client that is configured to work with the standard environment variables that are used in our services.
288
+
289
+ It is a pre-configured instance of [ioredis](https://github.com/luin/ioredis). See the package documentation for more details.
290
+
291
+ ```javascript
292
+ import { Redis } from 'node-server-engine';
293
+
294
+ await Redis.set(key, value);
295
+ ```
296
+
297
+ It can be configured through environment variables
298
+
299
+ | env | description | default |
300
+ | -------------- | ---------------------------------------------------------------------------------- | ------- |
301
+ | REDIS_HOST | Host to which to connecto to | |
302
+ | REDIS_PORT | Port on which redis is served | |
303
+ | REDIS_PASSWORD | Password used to authenticate with the server | |
304
+ | REDIS_CLUSTER | Flag indicating that redis is configured as a cluster and not as a single instance | false |
305
+
306
+ ---
307
+
308
+ ### Sequelize
309
+
310
+ The server engine exposes an SQL ORM that is configured to work with the standard environment variables that are used in our services.
311
+
312
+ It is a pre-configured instance of [sequelize](https://github.com/sequelize/sequelize). See the package documentation for more details.
313
+
314
+ ```javascript
315
+ import { Sequelize } from 'node-server-engine';
316
+
317
+ Sequelize.sequelize;
318
+ Sequelize.closeSequelize();
319
+ ```
320
+
321
+ It can be configured through environment variables
322
+
323
+ | env | description | default |
324
+ | ------------ | ------------------------------------------------- | -------- |
325
+ | SQL_HOST | Host to which connect to | |
326
+ | SQL_PORT | Port on which SQL is served | 5432 |
327
+ | SQL_PASSWORD | Password used to authenticate with the SQL server | |
328
+ | SQL_USER | User used to authenticate with the SQL server | |
329
+ | SQL_DB | Database to which connect to | |
330
+ | SQL_TYPE | SQL type which connect to | postgres |
331
+
332
+ ---
333
+
334
+ ### Pub/Sub
335
+
336
+ The engine exposes a `PubSub` entity that can be used to communicate with Google Cloud Pub/Sub.
337
+
338
+ ```javascript
339
+ import { PubSub } from 'node-server-engine';
340
+
341
+ /**
342
+ * Declare that the service will be publishing to a topic
343
+ * This must be done before init() is called
344
+ * Any attempt to publish a message without declaring a topic first will fail
345
+ * @property {string|Array.<string>} topic - The topic(s) to which we will be publishing
346
+ */
347
+ PubSub.addPublisher(topic);
348
+
349
+ /**
350
+ * Binds a message handle to a subscription
351
+ * If called multiple times, handlers will be chained
352
+ * This must be done before init() is called
353
+ * The subscription will not be consumed until init() is called
354
+ * @property {string} subscription - The subscription to consume
355
+ * @property {function|Array.<function>} handler - The message handling function(s)
356
+ * @property {boolean} [first] - Puts the handler(s) at the beginning of the handling chain (default: false)
357
+ */
358
+ PubSub.addSubscriber(subscription, handler, first);
359
+
360
+ /**
361
+ * Establish connection with all the declared publishers/subscribers
362
+ */
363
+ await PubSub.init();
364
+
365
+ /**
366
+ * Send a message through a previously declared publisher
367
+ * @property {string} topic - The name of the topic to which the message should be pushed
368
+ * @property {Object} message - The actual message (will be JSON stringified)
369
+ * @property {Object} [attributes] - Message attributes
370
+ * @property {string} [orderingKey] - Ordering key
371
+ */
372
+ await PubSub.publish(topic, message, attributes, orderingKey);
373
+
374
+ /**
375
+ * Flush all pending messages and close connections with Pub/Sub
376
+ */
377
+ await PubSub.shutdown();
378
+ ```
379
+
380
+ ---
381
+
382
+ ### MediaProcessor
383
+
384
+ Communication interface with the media processing service.
385
+
386
+ ```javascript
387
+ import { MediaProcessor } from 'node-server-engine';
388
+
389
+ /**
390
+ * Listener that will be called when the media processor has finished processing a given job group
391
+ * @param {string} id - The same id as the one given in the "process" function
392
+ * @param {boolean} success - Indicates success or failure of the jobs
393
+ */
394
+ function listener(id, success) {}
395
+
396
+ MediaProcessor.addListener(listener);
397
+
398
+ // The entity needs to initialize it's pub/sub connections
399
+ // Handlers must be declared before this function is called
400
+ await MediaProcessor.init();
401
+
402
+ /**
403
+ * Start a task with some processing jobs@
404
+ * @param {string} id - Identifier used to recognize the job when it returns
405
+ * @param {Job|Array.<Job>} - The job(s) to run
406
+ */
407
+ await MediaProcessor.process(id, jobs);
408
+
409
+ // This should be call when the program shuts down.
410
+ await MediaProcessor.shutdown();
411
+ ```
412
+
413
+ ---
414
+
415
+ ### PushNotification
416
+
417
+ Communication interface with the push service.
418
+
419
+ ```javascript
420
+ import { PushNotification } from 'node-server-engine';
421
+
422
+ // The entity needs to initialize it's pub/sub connections
423
+ // Handlers must be declared before this function is called
424
+ await PushNotification.init();
425
+
426
+ /**
427
+ * Send a push notification through the push service
428
+ * @param {String} userId - ID of the user that should receive the notification
429
+ * @param {Object} notification - Notification that should be sent
430
+ * @return {void}
431
+ */
432
+ await PushNotification.sendPush(userId, notification);
433
+ ```
434
+
435
+ ---
436
+
437
+ ### Localizator
438
+
439
+ The localizator exposes localization related utilities.
440
+
441
+ ```javascript
442
+ import { Localizator } from 'node-server-engine';
443
+
444
+ // The synchronize init should be called first to initialize the data
445
+ // The localizator will regularly synchronize new data after that without any calls having to be made
446
+ await Localizator.init();
447
+
448
+ // Get the different ways of displaying a user's name
449
+ const { regular, formal, casual } = await Localizator.getDisplayNames(
450
+ firstName,
451
+ lastName,
452
+ locale
453
+ );
454
+
455
+ // This should be call when the program shuts down.
456
+ await Localizator.shutdown();
457
+ ```
458
+
459
+ | env | description | default |
460
+ | ----------- | ----------------------------------------- | ------------ |
461
+ | LOCALES_URL | Base URL where the locales data is stored | **required** |
462
+
463
+ ---
464
+
465
+ ### ElasticSearch
466
+
467
+ The ElasticSearch exposes a service related to data searching.
468
+
469
+ ```javascript
470
+ import { ElasticSearch } from 'node-server-engine';
471
+
472
+ // The synchronize init should be called first to initialize the data
473
+ await ElasticSearch.init();
474
+
475
+ // This should be call when the program shuts down.
476
+ await ElasticSearch.shutdown();
477
+ ```
478
+
479
+ | env | description | default |
480
+ | ----------------------------- | ---------------------------------------------- | ------------ |
481
+ | ELASTIC_SEARCH_MIGRATION_PATH | The path link to Elastic Search migration data | **required** |
482
+ | ELASTIC_SEARCH_HOST | The elastic search host url | **required** |
483
+ | ELASTIC_SEARCH_USERNAME | The elastic search user name | **required** |
484
+ | ELASTIC_SEARCH_PASSWORD | The elastic search password | **required** |
485
+ | TLS_CA | CA for ssl config when available | |
486
+
487
+ ---
488
+
489
+ ### Translation Manager
490
+
491
+ The translation manager exposes translation related utilities.
492
+
493
+ ```javascript
494
+ import { TranslationManager } from 'node-server-engine';
495
+
496
+ // The synchronize init should be called first to initialize the data
497
+ // The tranlsation manager will regularly synchronize new data after that without any calls having to be made
498
+ await TranslationManager.init();
499
+
500
+ // Get the different ways of displaying a user's name
501
+ const translatedString = await TranslationManager.translate(
502
+ lang,
503
+ key,
504
+ variables,
505
+ tags
506
+ );
507
+
508
+ // Example
509
+ const translatedString = await TranslationManager.translate(
510
+ 'zh-TW',
511
+ 'email.invitation.body',
512
+ { name: 'John' },
513
+ { link: ['a', 'href="https://www.test.com"'] }
514
+ );
515
+
516
+ // This should be call when the program shuts down.
517
+ await TranslationManager.shutdown();
518
+ ```
519
+
520
+ - **lang** [String]: Locale for which the translation should be fetched (if no data is found, translation will be returned in `en-US`).
521
+ - **key** [String]: Translation key
522
+ - **variables** [Object]: A key=>value mapping for variable interpolation in strings. **(Optional)**
523
+ - **tags** [Object]: A key=>value mapping for variable interpolation in strings. **(Optional)**
524
+
525
+ | env | description | default |
526
+ | ----------- | ----------------------------------------- | ------------ |
527
+ | LOCALES_URL | Base URL where the locales data is stored | **required** |
528
+
529
+ ---
530
+
531
+ ### Error Reporting
532
+
533
+ The server engine standardizes the way errors are handled and reported. The error classes provided by the Server Engine should always be used when throwing an exception.
534
+
535
+ Errors are a crucial part of the application, they are what helps us to properly debug the program and offer support when need, as well as what exposes issues to the client.
536
+
537
+ By standard, the client receives the following body when an error happens.
538
+
539
+ ```javascript
540
+ // HTTP Status code (400 | 500)
541
+ {
542
+ errorCode: "some-error", // Machine readable error code
543
+ hint: "The selected user does not exist" // (optional) Hint for developers
544
+ }
545
+ ```
546
+
547
+ Status codes should be limited to 400 for client errors and 500 for server errors. Other 4XX status codes should be avoided unless very specific cases (ex: authentication error).
548
+
549
+ All our custom error classes take a `data` parameter. This will be logged on the backend and should contain any data that can help to understand the runtime context or the error (ex: user's ID).
550
+
551
+ #### Common options
552
+
553
+ These options are common to each of the error classes described below.
554
+
555
+ | option | definition | example | default |
556
+ | -------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ------------------------------ |
557
+ | message | A message logged on the backend only | "Could not find user in the DB" | **required** |
558
+ | severity | The level at which this error should be logged | [Severity](#severity).WARNING | [Severity](#severity).CRITICAL |
559
+ | data | Some data related to the error that will be logged on the backend. This should help to undetrstand the runtime context. | {userId: 'xf563ugh0', isAdmin: false} | |
560
+ | error | An error object, when this is a wrapper around an existing error object | |
561
+
562
+ #### Severity
563
+
564
+ Severity allows us to order errors by their impact on the program. It is important to set severity correctly as backend logs can include hundreds of entries per seconds, severity allows us to filter out the most important errors. An enumeration is exposed that includes all the severity levels, as described in the following table.
565
+
566
+ ##### Log Levels
567
+
568
+ | severity | definition |
569
+ | --------- | ------------------------------------------------------------------------------------------------------------------------ |
570
+ | DEBUG | Detailed information of the runtime execution. Used for debugging. |
571
+ | INFO | Base information level of runtime information. |
572
+ | WARNING | Errors that are expected to happen and do not cause any particular issue. (ex: a client made an unauthenticated request) |
573
+ | CRITICAL | Errors that are unexpected and cause an improper behavior. (ex: failed to store some data in the DB) |
574
+ | EMERGENCY | Errors that prevent the program from running. (ex: some environment variables are not correctly set) |
575
+
576
+ #### EngineError
577
+
578
+ This error class represents errors that happen withing the Server Engine. They should be used for server configuration errors, or unexpected behaviors. They will always return `500 - {errorCode: 'server-error'}`.
579
+
580
+ ```javascript
581
+ import { EngineError, Severity } from 'node-server-engine';
582
+
583
+ if (!process.env.IMPORTANT_VARIABLE) {
584
+ throw new EngineError(options);
585
+ }
586
+ ```
587
+
588
+ Engine Errors strictly follow the [common options](#common-options).
589
+
590
+ #### WebError
591
+
592
+ This error class represents errors that happen at runtime and that need specific reporting to the client. Their definition is more complex, but it includes additional data specific to the client.
593
+
594
+ ```javascript
595
+ import { WebError, Severity } from 'node-server-engine';
596
+
597
+ const user = User.findOne({ where: { id: userId } });
598
+ if (!user) {
599
+ throw new WebError(options);
600
+ }
601
+ ```
602
+
603
+ In addition to the [common options](#common-options), WebError defines some other options specific for error reporting to clients.
604
+
605
+ | option | definition | example | default |
606
+ | ---------- | ---------------------------------------------------------------- | ------------ | ------------ |
607
+ | errorCode | A machine readable error code that will be parsed by the client. | unknown-user | **required** |
608
+ | statusCode | HTTP status code of the response. | 400 | 500 |
609
+ | hint | A human readable error message that is intended for developers | |
610
+
611
+ ## Middlewares
612
+
613
+ Server engine exposes a bunch of middlewares. These can be imported to your project and used globally or per endpoint.
614
+
615
+ ### Swagger Docs
616
+
617
+ This middleware allows the service to connect with the [API Documentation Service](https://github.com/prakashmahendran/api-documentation-service). It exposes the necessary endpoint for the documentation of this API to be visible by the Documentation Service.
618
+
619
+ ```javascript
620
+ import { Server, middleware } from 'node-server-engine';
621
+
622
+ new Server({
623
+ globalMiddleware: [middleware.swaggerDocs()]
624
+ });
625
+ ```
626
+
627
+ #### Structuring Documentation
628
+
629
+ The underlying system used is the [Open API](https://swagger.io/specification/) spec.
630
+ Most of the data is already generate by the documentation service. The only real need is to document endpoints.
631
+
632
+ Endpoints should be documented in YAML files that respect the `**/*.docs.yaml` convention. It is recommended to place them in the same directory as the endpoint definition. Endpoint documentation has to follow the [path object spec](https://swagger.io/specification/#paths-object) from Open API.
633
+
634
+ ```yaml
635
+ /hello:
636
+ get:
637
+ description: Request the API to say Hello
638
+ responses:
639
+ '200':
640
+ description: Replies hello
641
+ content:
642
+ application/json:
643
+ schema:
644
+ type: Object
645
+ properties:
646
+ says:
647
+ type: string
648
+ example: Hello
649
+ ```
650
+
651
+ #### Schemas and Responses
652
+
653
+ To avoid repeating the same structure across the documentation manually, one can use [schemas and responses components](https://swagger.io/docs/specification/components/).
654
+
655
+ Some common components are already defined directly in the API Documentation Service, please check its documentation to avoid repeats.
656
+
657
+ If you ever need to declare custom components, they simply must follow the architecture bellow.
658
+
659
+ ```bash
660
+ # Repository root
661
+ /src
662
+ /docs
663
+ /responses
664
+ - coolResponse.yaml
665
+ / schemas
666
+ - bestSchema.yaml
667
+ ```
668
+
669
+ Here is an example definition:
670
+
671
+ ```yaml
672
+ Dog:
673
+ type: object
674
+ properties:
675
+ name:
676
+ type: string
677
+ example: Rex
678
+ owner:
679
+ type: string
680
+ example: f1982af0-1579-4c56-a138-de1ab4ff39b3
681
+ isAGoodBoy:
682
+ type: boolean
683
+ example: true
684
+ required:
685
+ - name
686
+ - owner
687
+ ```
688
+
689
+ ---
690
+
691
+ ### User Resolver
692
+
693
+ `/!\` **Must be used in combination with AuthType.JWT**
694
+
695
+ Resolves the user making the request with the user resolver. The user's complete data is added to `req.user`.
696
+
697
+ ```javascript
698
+ import { Endpoint, middleware, AuthType, Method } from 'node-server-engine';
699
+
700
+ new Endpoint({
701
+ path: '/hello',
702
+ method: Method.GET,
703
+ authType: AuthType.JWT,
704
+ middleware: [middleware.userResolver],
705
+ handler: (req, res) => {
706
+ res.json({ say: `Hello ${req.user.firstName}` });
707
+ }
708
+ });
709
+ ```
710
+
711
+ ## Utilities
712
+
713
+ The server engine ships with a handful of utility functions that are commonly used by servers
714
+
715
+ ### Request
716
+
717
+ This function is a wrapper around [axios](https://github.com/axios/axios). It adds proper error handling for reporting in the logs when a network call fails. It should be used for any requests made by a service.
718
+ Refer to the [axios documentation](https://github.com/axios/axios) for the request configuration.
719
+
720
+ ```javascript
721
+ import { request } from 'node-server-engine';
722
+ const { data } = await request({
723
+ method: 'get',
724
+ url: 'https://www.google.com'
725
+ });
726
+ ```
727
+
728
+ ---
729
+
730
+ ### TLS Request
731
+
732
+ This function is a wrapper around [request](#request). It adds the necessary configuration to easily make requests with TLS. The settings used are based on the environment variables. It will use request specific certificate/key if defined, or will fallback to use the same ones as the ones used for the server.
733
+
734
+ It is necessary to use this function when calling other services in the cluster. Requests could fail otherwise as the common CA is not set and the client certificate not exposed.
735
+
736
+ ```javascript
737
+ import { tlsRequest } from 'node-server-engine';
738
+ const { data } = await tlsRequest({
739
+ method: 'get',
740
+ url: 'https://www.google.com'
741
+ });
742
+ ```
743
+
744
+ ---
745
+
746
+ ### TLS Config
747
+
748
+ The server's TLS configuration can be fetched as an object. Alternatively, the server engine also exposes an [HTTPS Agent](https://nodejs.org/api/https.html#https_class_https_agent). They will not be available at startup, so it is important that the function calling them loads them first if they are not present.
749
+
750
+ ```javascript
751
+ import {tlsConfig, httpsAgent, loadTlsConfig} from 'node-server-engine';
752
+ import https from 'https';
753
+
754
+ // TLS Config
755
+ if(!tlsConfig) loadTlsConfig();
756
+ const customAgent = new https.Agent({
757
+ key: tlsConfig.key,
758
+ cert: tlsConfig.cert,
759
+ ca: tlsConfig.ca,
760
+ passphrase: tlsConfig.passphrase,
761
+ });
762
+
763
+ // HTTPS Agent
764
+ if(!httpsAgent) loadTlsConfig();
765
+ https.request('https://www.google.com'. {agent: httpsAgent});
766
+ ```
767
+
768
+ ---
769
+
770
+ ### Send Push Notification
771
+
772
+ Send a push notification through the push service.
773
+
774
+ ```javascript
775
+ import { sendPush } from 'node-server-engine';
776
+ await sendPush(userId, notification);
777
+ ```
778
+
779
+ | parameter | description |
780
+ | ------------ | ------------------------------------------------------------------------ |
781
+ | userId | ID of the user that should receive the notification |
782
+ | notification | Content of the notification as defined by the push service documentation |
783
+
784
+ ---
785
+
786
+ ---
787
+
788
+ ### Send Email
789
+
790
+ Send an email through the email service.
791
+
792
+ ```javascript
793
+ import { sendEmail } from 'node-server-engine';
794
+ await sendEmail(userId, template, translationKey, parameters, tags, to);
795
+ ```
796
+
797
+ | parameter | description |
798
+ | -------------- | -------------------------------------------------------------------------- |
799
+ | userId | ID of the user that should receive the notification |
800
+ | template | Email template to use |
801
+ | translationKey | Key used to get localized strings |
802
+ | parameters | Variables that can be inserted in the email template and localized strings |
803
+ | tags | Data injected in the localized strings as HTML tags |
804
+ | to | Array of email recipients |
805
+ | to.\*.email | Email of an email recipient |
806
+ | to.\*.name | Name of an email recipient |
807
+
808
+ ---
809
+
810
+ ### Filter
811
+
812
+ Apply a filter on an object. It returns a copy of the object that only holds the whitelisted keys.
813
+
814
+ This is particularly useful to sanitize objects before returning them to clients.
815
+
816
+ ```javascript
817
+ import { filter } from 'node-server-engine';
818
+
819
+ const object = { a: 'kept', b: 'not kept' };
820
+ const whitelist = ['a'];
821
+
822
+ const result = filter(object.whitelist);
823
+ // result = {a: 'kept'}
824
+ ```
825
+
826
+ ---
827
+
828
+ ### Database Migration
829
+
830
+ Some utilities are exposed to handle database migrations.
831
+
832
+ `runPendingMigrations` will execute all the migration scripts that have not yet been executed.
833
+
834
+ `rollbackMigrations` will rollback all the migrations that have been executed with the current version of the app and after.
835
+
836
+ ```javascript
837
+ import { runPendingMigrations } from 'node-server-engine';
838
+ import { rollbackMigrations } from 'node-server-engine';
839
+
840
+ await runPendingMigrations();
841
+
842
+ await rollbackMigrations();
843
+ ```
844
+
845
+ ---
846
+
847
+ ### Environment Variables Verification
848
+
849
+ Environment variables verification can be done through the [Server](#server)'s checkEnvironment setting. It is an object defining how environment variables should be verified.
850
+
851
+ ```javascript
852
+ import { envAssert } from 'node-server-engine';
853
+
854
+ export const checkEnvironment = {
855
+ ENV_VAR: envAssert.isString()
856
+ };
857
+ ```
858
+
859
+ #### Assertions Available
860
+
861
+ The sever engine makes available a utility for environment variables assertions calls `envAssert`. The following example shows the different assertions that are possible.
862
+
863
+ <!-- markdownlint-disable MD033 -->
864
+
865
+ | Validator | Description |
866
+ | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
867
+ | **isAfter(date])** | check if the string is a date that's after the specified date (defaults to now). |
868
+ | **isAlpha(locale, options])** | check if the string contains only letters (a-zA-Z).<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fa-IR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphaLocales`. options is an optional object that can be supplied with the following key(s): ignore which can either be a String or RegExp of characters to be ignored e.g. " -" will ignore spaces and -'s. |
869
+ | **isAlphanumeric(locale])** | check if the string contains only letters and numbers.<br/><br/>Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'fa-IR', 'he', 'hu-HU', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sk-SK', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`) and defaults to `en-US`. Locale list is `validator.isAlphanumericLocales`. |
870
+ | **isAscii()** | check if the string contains ASCII chars only. |
871
+ | **isBase32()** | check if a string is base32 encoded. |
872
+ | **isBase58()** | check if a string is base58 encoded. |
873
+ | **isBase64(options])** | check if a string is base64 encoded. options is optional and defaults to `{urlSafe: false}`<br/> when `urlSafe` is true it tests the given base64 encoded string is [url safe](https://base64.guru/standards/base64url) |
874
+ | **isBefore(date])** | check if the string is a date that's before the specified date. |
875
+ | **isBIC()** | check if a string is a BIC (Bank Identification Code) or SWIFT code. |
876
+ | **isBoolean()** | check if a string is a boolean. |
877
+ | **isBtcAddress()** | check if the string is a valid BTC address. |
878
+ | **isByteLength(options])** | check if the string's length (in UTF-8 bytes) falls in a range.<br/><br/>`options` is an object which defaults to `{min:0, max: undefined}`. |
879
+ | **isCreditCard()** | check if the string is a credit card. |
880
+ | **isCurrency(options])** | check if the string is a valid currency amount.<br/><br/>`options` is an object which defaults to `{symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false}`.<br/>**Note:** The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range 1 to 3 will be given as [1, 2, 3]. |
881
+ | **isDataURI()** | check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs). |
882
+ | **isDate(input [, options])** | Check if the input is a valid date. e.g. [`2002-07-15`, new Date()].<br/><br/> `options` is an object which can contain the keys `format`, `strictMode` and/or `delimiters`<br/><br/>`format` is a string and defaults to `YYYY/MM/DD`.<br/><br/>`strictMode` is a boolean and defaults to `false`. If `strictMode` is set to true, the validator will reject inputs different from `format`.<br/><br/> `delimiters` is an array of allowed date delimiters and defaults to `['/', '-']`. |
883
+ | **isDecimal(options])** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.<br/><br/>`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`<br/><br/>`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fa', 'fa-AF', 'fa-IR', 'fr-FR', 'hu-HU', 'id-ID', 'it-IT', 'ku-IQ', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pl-Pl', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']`.<br/>**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'. |
884
+ | **isDivisibleBy(number)** | check if the string is a number that's divisible by another. |
885
+ | **isEAN()** | check if the string is an EAN (European Article Number). |
886
+ | **isEmail(options])** | check if the string is an email.<br/><br/>`options` is an object which defaults to `{ allow_display_name: false, require_display_name: false, allow_utf8_local_part: true, require_tld: true, allow_ip_domain: false, domain_specific_validation: false, blacklisted_chars: '' }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `require_display_name` is set to true, the validator will reject strings without the format `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. If `ignore_max_length` is set to true, the validator will not check for the standard max length of an email. If `allow_ip_domain` is set to true, the validator will allow IP addresses in the host part. If `domain_specific_validation` is true, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail. If `blacklisted_chars` recieves a string,then the validator will reject emails that include any of the characters in the string, in the name part. |
887
+ | **isEmpty(options])** | check if the string has a length of zero.<br/><br/>`options` is an object which defaults to `{ ignore_whitespace:false }`. |
888
+ | **isEthereumAddress()** | check if the string is an [Ethereum](https://ethereum.org/) address using basic regex. Does not validate address checksums. |
889
+ | **isFloat(options])** | check if the string is a float.<br/><br/>`options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`) it also has `locale` as an option.<br/><br/>`min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts.<br/><br/>`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. Locale list is `validator.isFloatLocales`. |
890
+ | **isFQDN(options])** | check if the string is a fully qualified domain name (e.g. domain.com).<br/><br/>`options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false , allow_numeric_tld: false }`. |
891
+ | **isFullWidth()** | check if the string contains any full-width chars. |
892
+ | **isHalfWidth()** | check if the string contains any half-width chars. |
893
+ | **isHash(algorithm)** | check if the string is a hash of type algorithm.<br/><br/>Algorithm is one of `['md4', 'md5', 'sha1', 'sha256', 'sha384', 'sha512', 'ripemd128', 'ripemd160', 'tiger128', 'tiger160', 'tiger192', 'crc32', 'crc32b']` |
894
+ | **isHexadecimal()** | check if the string is a hexadecimal number. |
895
+ | **isHexColor()** | check if the string is a hexadecimal color. |
896
+ | **isHost()** | check if the string is a server host name. |
897
+ | **isHostList()** | check if the string is a comma separated list of server host name. |
898
+ | **isHSL()** | check if the string is an HSL (hue, saturation, lightness, optional alpha) color based on [CSS Colors Level 4 specification](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value).<br/><br/>Comma-separated format supported. Space-separated format supported with the exception of a few edge cases (ex: `hsl(200grad+.1%62%/1)`). |
899
+ | **isIBAN()** | check if a string is a IBAN (International Bank Account Number). |
900
+ | **isIdentityCard(locale])** | check if the string is a valid identity card code.<br/><br/>`locale` is one of `['ES', 'IN', 'IT', 'NO', 'zh-TW', 'he-IL', 'ar-TN', 'zh-CN']` OR `'any'`. If 'any' is used, function will check if any of the locals match.<br/><br/>Defaults to 'any'. |
901
+ | **isIMEI(options]))** | check if the string is a valid IMEI number. Imei should be of format `###############` or `##-######-######-#`.<br/><br/>`options` is an object which can contain the keys `allow_hyphens`. Defaults to first format . If allow_hyphens is set to true, the validator will validate the second format. |
902
+ | **isIn(values)** | check if the string is in a array of allowed values. |
903
+ | **isInt(options])** | check if the string is an integer.<br/><br/>`options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). `options` can also contain the key `allow_leading_zeroes`, which when set to false will disallow integer values with leading zeroes (e.g. `{ allow_leading_zeroes: false }`). Finally, `options` can contain the keys `gt` and/or `lt` which will enforce integers being greater than or less than, respectively, the value provided (e.g. `{gt: 1, lt: 4}` for a number between 1 and 4). |
904
+ | **isIP(version])** | check if the string is an IP (version 4 or 6). |
905
+ | **isIPList()** | check if the string is a comma separated list of IP addresses (version 4 or 6). |
906
+ | **isIPRange()** | check if the string is an IP Range(version 4 only). |
907
+ | **isISBN(version])** | check if the string is an ISBN (version 10 or 13). |
908
+ | **isISIN()** | check if the string is an [ISIN][isin] (stock/security identifier). |
909
+ | **isISO8601()** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date; for additional checks for valid dates, e.g. invalidates dates like `2009-02-29`, pass `options` object as a second parameter with `options.strict = true`. |
910
+ | **isISO31661Alpha2()** | check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code. |
911
+ | **isISO31661Alpha3()** | check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code. |
912
+ | **isISRC()** | check if the string is a [ISRC](https://en.wikipedia.org/wiki/International_Standard_Recording_Code). |
913
+ | **isISSN(options])** | check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).<br/><br/>`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected. |
914
+ | **isJSON(options])** | check if the string is valid JSON (note: uses JSON.parse).<br/><br/>`options` is an object which defaults to `{ allow_primitives: false }`. If `allow_primitives` is true, the primitives 'true', 'false' and 'null' are accepted as valid JSON values. |
915
+ | **isJWT()** | check if the string is valid JWT token. |
916
+ | **isLatLong(options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format. |
917
+ | **isLength(options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs. |
918
+ | **isLocale()** | check if the string is a locale |
919
+ | **isLowercase()** | check if the string is lowercase. |
920
+ | **isMACAddress()** | check if the string is a MAC address.<br/><br/>`options` is an object which defaults to `{no_colons: false}`. If `no_colons` is true, the validator will allow MAC addresses without the colons. Also, it allows the use of hyphens, spaces or dots e.g '01 02 03 04 05 ab', '01-02-03-04-05-ab' or '0102.0304.05ab'. |
921
+ | **isMagnetURI()** | check if the string is a [magnet uri format](https://en.wikipedia.org/wiki/Magnet_URI_scheme). |
922
+ | **isMD5()** | check if the string is a MD5 hash.<br/><br/>Please note that you can also use the `isHash('md5')` function. Keep in mind that MD5 has some collision weaknesses compared to other algorithms (e.g., SHA). |
923
+ | **isMimeType()** | check if the string matches to a valid [MIME type](https://en.wikipedia.org/wiki/Media_type) format |
924
+ | **isMobilePhone(locale [, options]])** | check if the string is a mobile phone number,<br/><br/>(locale is either an array of locales (e.g `['sk-SK', 'sr-RS']`) OR one of `['am-Am', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', ar-JO', 'ar-KW', 'ar-MA', 'ar-SA', 'ar-SY', 'ar-TN', 'az-AZ', 'az-LY', 'az-LB', 'bs-BA', 'be-BY', 'bg-BG', 'bn-BD', 'ca-AD', 'cs-CZ', 'da-DK', 'de-DE', 'de-AT', 'de-CH', 'de-LU', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GG', 'en-GH', 'en-HK', 'en-MO', 'en-IE', 'en-IN', 'en-KE', 'en-MT', 'en-MU', 'en-NG', 'en-NZ', 'en-PK', 'en-PH', 'en-RW', 'en-SG', 'en-SL', 'en-UG', 'en-US', 'en-TZ', 'en-ZA', 'en-ZM', 'en-ZW', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-DO', 'es-HN', 'es-PE', 'es-EC', 'es-ES', 'es-MX', 'es-PA', 'es-PY', 'es-UY', 'et-EE', 'fa-IR', 'fi-FI', 'fj-FJ', 'fo-FO', 'fr-BE', 'fr-FR', 'fr-GF', 'fr-GP', 'fr-MQ', 'fr-RE', 'ga-IE', 'he-IL', 'hu-HU', 'id-ID', 'it-IT', 'it-SM', 'ja-JP', 'ka-GE', 'kk-KZ', 'kl-GL', 'ko-KR', 'lt-LT', 'ms-MY', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sl-SI', 'sk-SK', 'sq-AL', 'sr-RS', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'zh-CN', 'zh-HK', 'zh-MO', 'zh-TW']` OR defaults to 'any'. If 'any' or a falsey value is used, function will check if any of the locales match).<br/><br/>`options` is an optional object that can be supplied with the following keys: `strictMode`, if this is set to `true`, the mobile phone number must be supplied with the country code and therefore must start with `+`. Locale list is `validator.isMobilePhoneLocales`. |
925
+ | **isMongoId()** | check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. |
926
+ | **isMultibyte()** | check if the string contains one or more multi-byte chars. |
927
+ | **isNumber** | check if the string contains only numbers. |
928
+ | **isNumeric(options])** | check if the string contains only numbers.<br/><br/>`options` is an object which defaults to `{no_symbols: false}` it also has locale as an option. If `no_symbols` is true, the validator will reject numeric strings that feature a symbol (e.g. `+`, `-`, or `.`).<br/><br/>`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU', 'it-IT', 'nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`. |
929
+ | **isOctal()** | check if the string is a valid octal number. |
930
+ | **isPath()** | check if the string is a valid path. |
931
+ | **isPassportNumber(countryCode)** | check if the string is a valid passport number.<br/><br/>(countryCode is one of `[ 'AM', 'AR', 'AT', 'AU', 'BE', 'BG', 'BY', 'CA', 'CH', 'CN', 'CY', 'CZ', 'DE', 'DK', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE' 'IN', 'IS', 'IT', 'JP', 'KR', 'LT', 'LU', 'LV', 'MT', 'NL', 'PO', 'PT', 'RO', 'RU', 'SE', 'SL', 'SK', 'TR', 'UA', 'US' ]`. |
932
+ | **isPort()** | check if the string is a valid port number. |
933
+ | **isPostalCode(locale)** | check if the string is a postal code,<br/><br/>(locale is one of `[ 'AD', 'AT', 'AU', 'AZ', 'BE', 'BG', 'BR', 'BY', 'CA', 'CH', 'CZ', 'DE', 'DK', 'DO', 'DZ', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HT', 'HU', 'ID', 'IE' 'IL', 'IN', 'IR', 'IS', 'IT', 'JP', 'KE', 'LI', 'LT', 'LU', 'LV', 'MT', 'MX', 'MY', 'NL', 'NO', 'NP', 'NZ', 'PL', 'PR', 'PT', 'RO', 'RU', 'SA', 'SE', 'SG', 'SI', 'TH', 'TN', 'TW', 'UA', 'US', 'ZA', 'ZM' ]` OR 'any'. If 'any' is used, function will check if any of the locals match. Locale list is `validator.isPostalCodeLocales`.). |
934
+ | **isRFC3339()** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. |
935
+ | **isRgbColor(includePercentValues])** | check if the string is a rgb or rgba color.<br/><br/>`includePercentValues` defaults to `true`. If you don't want to allow to set `rgb` or `rgba` values with percents, like `rgb(5%,5%,5%)`, or `rgba(90%,90%,90%,.3)`, then set it to false. |
936
+ | **isSemVer()** | check if the string is a Semantic Versioning Specification (SemVer). |
937
+ | **isString()** | check if the string is a string. |
938
+ | **isStringList()** | check if the string is a comma separated list of string. |
939
+ | **isSurrogatePair()** | check if the string contains any surrogate pairs chars. |
940
+ | **isUppercase()** | check if the string is uppercase. |
941
+ | **isSlug** | Check if the string is of type slug. `Options` allow a single hyphen between string. e.g. [`cn-cn`, `cn-c-c`] |
942
+ | **isStrongPassword(options])** | Check if a password is strong or not. Allows for custom requirements or scoring rules. If `returnScore` is true, then the function returns an integer score for the password rather than a boolean.<br/>Default options: <br/>`{ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1, returnScore: false, pointsPerUnique: 1, pointsPerRepeat: 0.5, pointsForContainingLower: 10, pointsForContainingUpper: 10, pointsForContainingNumber: 10, pointsForContainingSymbol: 10 }` |
943
+ | **isTaxID(locale)** | Check if the given value is a valid Tax Identification Number. Default locale is `en-US` |
944
+ | **isURL(options])** | check if the string is an URL.<br/><br/>`options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_host: true, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false, disallow_auth: false }`.<br/><br/>require_protocol - if set as true isURL will return false if protocol is not present in the URL.<br/>require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option.<br/>protocols - valid protocols can be modified with this option.<br/>require_host - if set as false isURL will not check if host is present in the URL.<br/>require_port - if set as true isURL will check if port is present in the URL.<br/>allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed.<br/>validate_length - if set as false isURL will skip string length validation (2083 characters is IE max URL length). |
945
+ | **isUUID(version])** | check if the string is a UUID (version 3, 4 or 5). |
946
+ | **isVariableWidth()** | check if the string contains a mixture of full and half-width chars. |
947
+ | **isWhitelisted(chars)** | checks characters if they appear in the whitelist. |
948
+
949
+ #### Wait
950
+
951
+ Wait is used to make the process wait for the given seconds.
952
+
953
+ ```javascript
954
+ import { wait } from 'node-server-engine';
955
+
956
+ // This will make the process wait for 10 mins
957
+ await wait(600);
958
+ ```
959
+
960
+ <!-- markdownlint-enable MD033 -->