node-server-engine 1.1.1 → 1.1.3
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.
- package/.env.example +193 -193
- package/.mocharc.js +13 -13
- package/.nycrc +18 -18
- package/.prettierrc +7 -7
- package/Dockerfile +30 -30
- package/README.md +991 -1025
- package/babel.config.json +35 -35
- package/dist/const/DebeziumEvent.js.map +1 -1
- package/dist/const/LogSeverity.js.map +1 -1
- package/dist/const/index.js.map +1 -1
- package/dist/const/metrics.js.map +1 -1
- package/dist/const/mime.js.map +1 -1
- package/dist/const/tokenIssuer.js.map +1 -1
- package/dist/db/migrations/20241030121500-create-sequelize-meta-table.js.map +1 -1
- package/dist/db/models/SequelizeMeta.js.map +1 -1
- package/dist/db/models/index.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.js +7 -7
- package/dist/entities/ElasticSearch/ElasticSearch.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.types.js.map +1 -1
- package/dist/entities/ElasticSearch/index.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.js +8 -8
- package/dist/entities/Endpoint/Endpoint.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.types.js.map +1 -1
- package/dist/entities/Endpoint/index.js.map +1 -1
- package/dist/entities/EngineError/EngineError.js +2 -2
- package/dist/entities/EngineError/EngineError.js.map +1 -1
- package/dist/entities/EngineError/EngineError.types.js.map +1 -1
- package/dist/entities/EngineError/index.js.map +1 -1
- package/dist/entities/KeySet/KeySet.js +3 -3
- package/dist/entities/KeySet/KeySet.js.map +1 -1
- package/dist/entities/KeySet/KeySet.types.js.map +1 -1
- package/dist/entities/KeySet/index.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.types.js.map +1 -1
- package/dist/entities/LifecycleController/index.js.map +1 -1
- package/dist/entities/Localizator/Localizator.js +7 -7
- package/dist/entities/Localizator/Localizator.js.map +1 -1
- package/dist/entities/Localizator/Localizator.types.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/index.js.map +1 -1
- package/dist/entities/Localizator/index.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.js +2 -2
- package/dist/entities/MessageHandler/MessageHandler.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.types.js.map +1 -1
- package/dist/entities/MessageHandler/index.js.map +1 -1
- package/dist/entities/PubSub/PubSub.js +25 -25
- package/dist/entities/PubSub/PubSub.js.map +1 -1
- package/dist/entities/PubSub/PubSub.types.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/handleMessage.js +6 -6
- package/dist/entities/PubSub/handleMessage/handleMessage.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/index.js.map +1 -1
- package/dist/entities/PubSub/index.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.js +4 -4
- package/dist/entities/PushNotification/PushNotification.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.types.js.map +1 -1
- package/dist/entities/PushNotification/index.js.map +1 -1
- package/dist/entities/Redis/Redis.js +8 -8
- package/dist/entities/Redis/Redis.js.map +1 -1
- package/dist/entities/Redis/Redis.types.js.map +1 -1
- package/dist/entities/Redis/Redis.validate.js +2 -2
- package/dist/entities/Redis/Redis.validate.js.map +1 -1
- package/dist/entities/Redis/index.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.config.js +42 -2
- package/dist/entities/Sequelize/Sequelize.config.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.js +3 -3
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.types.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.validate.js +2 -2
- package/dist/entities/Sequelize/Sequelize.validate.js.map +1 -1
- package/dist/entities/Sequelize/index.js.map +1 -1
- package/dist/entities/Server/Server.const.js.map +1 -1
- package/dist/entities/Server/Server.js +2 -2
- package/dist/entities/Server/Server.js.map +1 -1
- package/dist/entities/Server/Server.types.js.map +1 -1
- package/dist/entities/Server/index.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.js +15 -15
- package/dist/entities/SocketClient/SocketClient.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.types.js.map +1 -1
- package/dist/entities/SocketClient/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/parseMessage.js +2 -2
- package/dist/entities/SocketClient/parseMessage/parseMessage.js.map +1 -1
- package/dist/entities/Storage/Storage.js +20 -20
- package/dist/entities/Storage/Storage.js.map +1 -1
- package/dist/entities/Storage/Storage.types.js.map +1 -1
- package/dist/entities/Storage/index.js.map +1 -1
- package/dist/entities/ValidationError/ValidationError.js.map +1 -1
- package/dist/entities/ValidationError/index.js.map +1 -1
- package/dist/entities/WebError/WebError.js +4 -4
- package/dist/entities/WebError/WebError.js.map +1 -1
- package/dist/entities/WebError/WebError.types.js.map +1 -1
- package/dist/entities/WebError/index.js.map +1 -1
- package/dist/entities/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/debug.js.map +1 -1
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/request.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.types.js.map +1 -1
- package/dist/middleware/authAdmin/index.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.types.js.map +1 -1
- package/dist/middleware/authHmac/index.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.types.js.map +1 -1
- package/dist/middleware/authJwt/index.js.map +1 -1
- package/dist/middleware/authStatic/authStatic.js +3 -3
- package/dist/middleware/authStatic/authStatic.js.map +1 -1
- package/dist/middleware/authStatic/index.js.map +1 -1
- package/dist/middleware/authTls/authTls.js +8 -8
- package/dist/middleware/authTls/authTls.js.map +1 -1
- package/dist/middleware/authTls/authTls.types.js.map +1 -1
- package/dist/middleware/authTls/index.js.map +1 -1
- package/dist/middleware/checkPermission/checkPermission.d.ts +3 -1
- package/dist/middleware/checkPermission/checkPermission.js +2 -2
- package/dist/middleware/checkPermission/checkPermission.js.map +1 -1
- package/dist/middleware/error/error.js.map +1 -1
- package/dist/middleware/error/index.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js +2 -2
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/index.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.js +12 -12
- package/dist/middleware/fileUploader/fileUploader.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.types.js.map +1 -1
- package/dist/middleware/fileUploader/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/isMultipart.js.map +1 -1
- package/dist/middleware/fileUploader/validate/index.js.map +1 -1
- package/dist/middleware/fileUploader/validate/validate.js.map +1 -1
- package/dist/middleware/fourOhFour/fourOhFour.js.map +1 -1
- package/dist/middleware/fourOhFour/index.js.map +1 -1
- package/dist/middleware/geminiFileUploader/geminiFileUploader.js.map +1 -1
- package/dist/middleware/geminiFileUploader/index.js.map +1 -1
- package/dist/middleware/healthCheck/healthCheck.js +2 -2
- package/dist/middleware/healthCheck/healthCheck.js.map +1 -1
- package/dist/middleware/healthCheck/index.js.map +1 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/metrics/index.js.map +1 -1
- package/dist/middleware/metrics/metrics.js.map +1 -1
- package/dist/middleware/requestMetrics/index.js.map +1 -1
- package/dist/middleware/requestMetrics/requestMetrics.js.map +1 -1
- package/dist/middleware/swaggerDocs/index.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.js +7 -7
- package/dist/middleware/swaggerDocs/swaggerDocs.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.types.js.map +1 -1
- package/dist/middleware/userResolver/index.js.map +1 -1
- package/dist/middleware/userResolver/userResolver.js.map +1 -1
- package/dist/middleware/validate/index.js.map +1 -1
- package/dist/middleware/validate/validate.js.map +1 -1
- package/dist/middleware/version/index.js.map +1 -1
- package/dist/middleware/version/version.js +3 -3
- package/dist/middleware/version/version.js.map +1 -1
- package/dist/utils/checkEnvironment/index.js +13 -13
- package/dist/utils/checkEnvironment/index.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.validate.js +2 -2
- package/dist/utils/createHttpServer/createHttpServer.validate.js.map +1 -1
- package/dist/utils/createHttpServer/index.js.map +1 -1
- package/dist/utils/createSortedObject/createSortedObject.js.map +1 -1
- package/dist/utils/createSortedObject/index.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.js +8 -8
- package/dist/utils/dbMigration/dbMigration.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.types.js.map +1 -1
- package/dist/utils/dbMigration/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.d.ts +2 -2
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js +47 -15
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js.map +1 -1
- package/dist/utils/envAssert/envAssert.js +6 -6
- package/dist/utils/envAssert/envAssert.js.map +1 -1
- package/dist/utils/envAssert/index.js.map +1 -1
- package/dist/utils/envAssert/validators/hostList.js +2 -2
- package/dist/utils/envAssert/validators/hostList.js.map +1 -1
- package/dist/utils/envAssert/validators/index.js.map +1 -1
- package/dist/utils/envAssert/validators/ipList.js +2 -2
- package/dist/utils/envAssert/validators/ipList.js.map +1 -1
- package/dist/utils/envAssert/validators/path.js +2 -2
- package/dist/utils/envAssert/validators/path.js.map +1 -1
- package/dist/utils/envAssert/validators/string.js +2 -2
- package/dist/utils/envAssert/validators/string.js.map +1 -1
- package/dist/utils/envAssert/validators/stringList.js +3 -3
- package/dist/utils/envAssert/validators/stringList.js.map +1 -1
- package/dist/utils/filter/filter.js +4 -4
- package/dist/utils/filter/filter.js.map +1 -1
- package/dist/utils/filter/index.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.types.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.validate.js.map +1 -1
- package/dist/utils/getDynamicLink/index.js.map +1 -1
- package/dist/utils/hmac/checkEnv/checkEnv.js +2 -2
- package/dist/utils/hmac/checkEnv/checkEnv.js.map +1 -1
- package/dist/utils/hmac/checkEnv/index.js.map +1 -1
- package/dist/utils/hmac/createHmac/createHmac.js.map +1 -1
- package/dist/utils/hmac/createHmac/index.js.map +1 -1
- package/dist/utils/hmac/index.js.map +1 -1
- package/dist/utils/hmac/index.types.js.map +1 -1
- package/dist/utils/hmac/signPayload/index.js.map +1 -1
- package/dist/utils/hmac/signPayload/signPayload.js.map +1 -1
- package/dist/utils/hmac/verifySignature/index.js.map +1 -1
- package/dist/utils/hmac/verifySignature/verifySignature.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jwt/index.js.map +1 -1
- package/dist/utils/jwt/jwt.js.map +1 -1
- package/dist/utils/jwt/jwt.types.js.map +1 -1
- package/dist/utils/report/index.js.map +1 -1
- package/dist/utils/report/output.js.map +1 -1
- package/dist/utils/report/output.types.js.map +1 -1
- package/dist/utils/report/report.js.map +1 -1
- package/dist/utils/report/report.types.js.map +1 -1
- package/dist/utils/request/index.js.map +1 -1
- package/dist/utils/request/request.js.map +1 -1
- package/dist/utils/semverCompare/index.js.map +1 -1
- package/dist/utils/semverCompare/semverCompare.js +5 -5
- package/dist/utils/semverCompare/semverCompare.js.map +1 -1
- package/dist/utils/sendEmail/index.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.js +8 -8
- package/dist/utils/sendEmail/sendEmail.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.types.js.map +1 -1
- package/dist/utils/sendPush/index.js.map +1 -1
- package/dist/utils/sendPush/sendPush.js +5 -5
- package/dist/utils/sendPush/sendPush.js.map +1 -1
- package/dist/utils/sendPush/sendPush.types.js.map +1 -1
- package/dist/utils/tlsConfig/index.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.types.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.validate.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.validate.js.map +1 -1
- package/dist/utils/tlsRequest/index.js.map +1 -1
- package/dist/utils/tlsRequest/tlsRequest.js.map +1 -1
- package/dist/utils/trimPathSlash/index.js.map +1 -1
- package/dist/utils/trimPathSlash/trimPathSlash.js +4 -4
- package/dist/utils/trimPathSlash/trimPathSlash.js.map +1 -1
- package/eslint.config.mjs +11 -11
- package/package.json +164 -161
- package/src/const/DebeziumEvent.ts +6 -6
- package/src/const/LogSeverity.ts +7 -7
- package/src/const/index.ts +5 -5
- package/src/const/metrics.ts +6 -6
- package/src/const/mime.ts +37 -37
- package/src/const/tokenIssuer.ts +9 -9
- package/src/db/migrations/20241030121500-create-sequelize-meta-table.ts +29 -29
- package/src/db/models/SequelizeMeta.ts +16 -16
- package/src/db/models/index.ts +2 -2
- package/src/entities/ElasticSearch/ElasticSearch.ts +103 -103
- package/src/entities/ElasticSearch/ElasticSearch.types.ts +7 -7
- package/src/entities/ElasticSearch/index.ts +2 -2
- package/src/entities/Endpoint/Endpoint.test.ts +337 -337
- package/src/entities/Endpoint/Endpoint.ts +202 -202
- package/src/entities/Endpoint/Endpoint.types.ts +205 -205
- package/src/entities/Endpoint/index.ts +2 -2
- package/src/entities/EngineError/EngineError.ts +28 -28
- package/src/entities/EngineError/EngineError.types.ts +15 -15
- package/src/entities/EngineError/index.ts +2 -2
- package/src/entities/KeySet/KeySet.test.ts +126 -126
- package/src/entities/KeySet/KeySet.ts +172 -172
- package/src/entities/KeySet/KeySet.types.ts +28 -28
- package/src/entities/KeySet/index.ts +2 -2
- package/src/entities/LifecycleController/LifecycleController.test.ts +48 -48
- package/src/entities/LifecycleController/LifecycleController.ts +24 -24
- package/src/entities/LifecycleController/LifecycleController.types.ts +5 -5
- package/src/entities/LifecycleController/index.ts +2 -2
- package/src/entities/Localizator/Localizator.ts +139 -139
- package/src/entities/Localizator/Localizator.types.ts +52 -52
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.test.ts +165 -165
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.ts +58 -58
- package/src/entities/Localizator/guessNamingConvention/index.ts +1 -1
- package/src/entities/Localizator/index.ts +2 -2
- package/src/entities/MessageHandler/MessageHandler.test.ts +130 -130
- package/src/entities/MessageHandler/MessageHandler.ts +72 -72
- package/src/entities/MessageHandler/MessageHandler.types.ts +15 -15
- package/src/entities/MessageHandler/index.ts +2 -2
- package/src/entities/PubSub/PubSub.test.ts +297 -297
- package/src/entities/PubSub/PubSub.ts +202 -202
- package/src/entities/PubSub/PubSub.types.ts +76 -76
- package/src/entities/PubSub/handleMessage/handleMessage.test.ts +102 -102
- package/src/entities/PubSub/handleMessage/handleMessage.ts +65 -65
- package/src/entities/PubSub/handleMessage/index.ts +1 -1
- package/src/entities/PubSub/index.ts +2 -2
- package/src/entities/PushNotification/PushNotification.test.ts +35 -35
- package/src/entities/PushNotification/PushNotification.ts +44 -44
- package/src/entities/PushNotification/PushNotification.types.ts +25 -25
- package/src/entities/PushNotification/index.ts +2 -2
- package/src/entities/Redis/Redis.ts +71 -71
- package/src/entities/Redis/Redis.types.ts +19 -19
- package/src/entities/Redis/Redis.validate.ts +17 -17
- package/src/entities/Redis/index.ts +2 -2
- package/src/entities/Sequelize/Sequelize.config.ts +59 -29
- package/src/entities/Sequelize/Sequelize.test.ts +21 -21
- package/src/entities/Sequelize/Sequelize.ts +75 -75
- package/src/entities/Sequelize/Sequelize.types.ts +10 -10
- package/src/entities/Sequelize/Sequelize.validate.ts +15 -15
- package/src/entities/Sequelize/index.ts +2 -2
- package/src/entities/Server/Server.const.ts +56 -56
- package/src/entities/Server/Server.test.ts +272 -272
- package/src/entities/Server/Server.ts +445 -445
- package/src/entities/Server/Server.types.ts +88 -88
- package/src/entities/Server/index.ts +2 -2
- package/src/entities/SocketClient/SocketClient.test.ts +392 -392
- package/src/entities/SocketClient/SocketClient.ts +401 -401
- package/src/entities/SocketClient/SocketClient.types.ts +62 -62
- package/src/entities/SocketClient/index.ts +2 -2
- package/src/entities/SocketClient/parseMessage/index.ts +1 -1
- package/src/entities/SocketClient/parseMessage/parseMessage.test.ts +20 -20
- package/src/entities/SocketClient/parseMessage/parseMessage.ts +26 -26
- package/src/entities/Storage/Storage.test.ts +58 -58
- package/src/entities/Storage/Storage.ts +219 -219
- package/src/entities/Storage/Storage.types.ts +57 -57
- package/src/entities/Storage/index.ts +2 -2
- package/src/entities/ValidationError/ValidationError.ts +34 -34
- package/src/entities/ValidationError/index.ts +1 -1
- package/src/entities/WebError/WebError.test.ts +18 -18
- package/src/entities/WebError/WebError.ts +23 -23
- package/src/entities/WebError/WebError.types.ts +9 -9
- package/src/entities/WebError/index.ts +2 -2
- package/src/entities/index.ts +16 -16
- package/src/index.ts +4 -4
- package/src/metrics/debug.ts +10 -10
- package/src/metrics/index.ts +2 -2
- package/src/metrics/request.ts +17 -17
- package/src/middleware/authAdmin/authAdmin.test.ts +199 -199
- package/src/middleware/authAdmin/authAdmin.ts +114 -114
- package/src/middleware/authAdmin/authAdmin.types.ts +19 -19
- package/src/middleware/authAdmin/index.ts +2 -2
- package/src/middleware/authHmac/authHmac.test.ts +86 -86
- package/src/middleware/authHmac/authHmac.ts +56 -56
- package/src/middleware/authHmac/authHmac.types.ts +7 -7
- package/src/middleware/authHmac/index.ts +2 -2
- package/src/middleware/authJwt/authJwt.test.ts +54 -54
- package/src/middleware/authJwt/authJwt.ts +55 -55
- package/src/middleware/authJwt/authJwt.types.ts +14 -14
- package/src/middleware/authJwt/index.ts +2 -2
- package/src/middleware/authStatic/authStatic.test.ts +36 -36
- package/src/middleware/authStatic/authStatic.ts +45 -45
- package/src/middleware/authStatic/index.ts +1 -1
- package/src/middleware/authTls/authTls.test.ts +138 -138
- package/src/middleware/authTls/authTls.ts +106 -106
- package/src/middleware/authTls/authTls.types.ts +13 -13
- package/src/middleware/authTls/index.ts +2 -2
- package/src/middleware/checkPermission/checkPermission.ts +33 -35
- package/src/middleware/error/error.test.ts +60 -60
- package/src/middleware/error/error.ts +25 -25
- package/src/middleware/error/index.ts +1 -1
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.ts +25 -25
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts +12 -12
- package/src/middleware/fileUploader/compressAvatar/index.ts +2 -2
- package/src/middleware/fileUploader/fileUploader.test.ts +310 -310
- package/src/middleware/fileUploader/fileUploader.ts +303 -303
- package/src/middleware/fileUploader/fileUploader.types.ts +52 -52
- package/src/middleware/fileUploader/index.ts +2 -2
- package/src/middleware/fileUploader/isMultiPart/index.ts +1 -1
- package/src/middleware/fileUploader/isMultiPart/isMultipart.ts +9 -9
- package/src/middleware/fileUploader/validate/index.ts +1 -1
- package/src/middleware/fileUploader/validate/validate.ts +27 -27
- package/src/middleware/fourOhFour/fourOhFour.test.ts +14 -14
- package/src/middleware/fourOhFour/fourOhFour.ts +13 -13
- package/src/middleware/fourOhFour/index.ts +1 -1
- package/src/middleware/geminiFileUploader/geminiFileUploader.ts +117 -117
- package/src/middleware/geminiFileUploader/index.ts +1 -1
- package/src/middleware/healthCheck/healthCheck.test.ts +12 -12
- package/src/middleware/healthCheck/healthCheck.ts +14 -14
- package/src/middleware/healthCheck/index.ts +1 -1
- package/src/middleware/index.ts +17 -17
- package/src/middleware/metrics/index.ts +1 -1
- package/src/middleware/metrics/metrics.test.ts +46 -46
- package/src/middleware/metrics/metrics.ts +24 -24
- package/src/middleware/requestMetrics/index.ts +1 -1
- package/src/middleware/requestMetrics/requestMetrics.test.ts +77 -77
- package/src/middleware/requestMetrics/requestMetrics.ts +20 -20
- package/src/middleware/swaggerDocs/index.ts +2 -2
- package/src/middleware/swaggerDocs/swaggerDocs.ts +114 -114
- package/src/middleware/swaggerDocs/swaggerDocs.types.ts +41 -41
- package/src/middleware/userResolver/index.ts +1 -1
- package/src/middleware/userResolver/userResolver.test.ts +35 -35
- package/src/middleware/userResolver/userResolver.ts +35 -35
- package/src/middleware/validate/index.ts +1 -1
- package/src/middleware/validate/validate.test.ts +43 -43
- package/src/middleware/validate/validate.ts +25 -25
- package/src/middleware/version/index.ts +1 -1
- package/src/middleware/version/version.test.ts +23 -23
- package/src/middleware/version/version.ts +12 -12
- package/src/utils/checkEnvironment/index.ts +49 -49
- package/src/utils/createHttpServer/createHttpServer.test.ts +24 -24
- package/src/utils/createHttpServer/createHttpServer.ts +34 -34
- package/src/utils/createHttpServer/createHttpServer.validate.ts +17 -17
- package/src/utils/createHttpServer/index.ts +1 -1
- package/src/utils/createSortedObject/createSortedObject.ts +20 -20
- package/src/utils/createSortedObject/createSortedObjet.test.ts +47 -47
- package/src/utils/createSortedObject/index.ts +1 -1
- package/src/utils/dbMigration/dbMigration.test.ts +209 -209
- package/src/utils/dbMigration/dbMigration.ts +199 -199
- package/src/utils/dbMigration/dbMigration.types.ts +11 -11
- package/src/utils/dbMigration/index.ts +2 -2
- package/src/utils/dbMigration/migrateMetadataTable/index.ts +1 -1
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.test.ts +59 -59
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts +102 -70
- package/src/utils/envAssert/envAssert.ts +31 -31
- package/src/utils/envAssert/index.ts +1 -1
- package/src/utils/envAssert/validators/hostList.ts +17 -17
- package/src/utils/envAssert/validators/index.ts +5 -5
- package/src/utils/envAssert/validators/ipList.ts +13 -13
- package/src/utils/envAssert/validators/path.ts +13 -13
- package/src/utils/envAssert/validators/string.ts +9 -9
- package/src/utils/envAssert/validators/stringList.ts +13 -13
- package/src/utils/filter/filter.ts +17 -17
- package/src/utils/filter/index.ts +1 -1
- package/src/utils/getDynamicLink/getDynamicLink.test.ts +51 -51
- package/src/utils/getDynamicLink/getDynamicLink.ts +28 -28
- package/src/utils/getDynamicLink/getDynamicLink.types.ts +11 -11
- package/src/utils/getDynamicLink/getDynamicLink.validate.ts +6 -6
- package/src/utils/getDynamicLink/index.ts +2 -2
- package/src/utils/hmac/checkEnv/checkEnv.test.ts +18 -18
- package/src/utils/hmac/checkEnv/checkEnv.ts +9 -9
- package/src/utils/hmac/checkEnv/index.ts +1 -1
- package/src/utils/hmac/createHmac/createHmac.ts +33 -33
- package/src/utils/hmac/createHmac/index.ts +1 -1
- package/src/utils/hmac/index.ts +4 -4
- package/src/utils/hmac/index.types.ts +13 -13
- package/src/utils/hmac/signPayload/index.ts +1 -1
- package/src/utils/hmac/signPayload/signPayload.ts +16 -16
- package/src/utils/hmac/verifySignature/index.ts +1 -1
- package/src/utils/hmac/verifySignature/verifySignature.ts +24 -24
- package/src/utils/index.ts +26 -26
- package/src/utils/jwt/index.ts +2 -2
- package/src/utils/jwt/jwt.test.ts +41 -41
- package/src/utils/jwt/jwt.ts +204 -204
- package/src/utils/jwt/jwt.types.ts +21 -21
- package/src/utils/report/index.ts +3 -3
- package/src/utils/report/output.ts +45 -45
- package/src/utils/report/output.types.ts +70 -70
- package/src/utils/report/report.test.ts +133 -133
- package/src/utils/report/report.ts +134 -134
- package/src/utils/report/report.types.ts +13 -13
- package/src/utils/request/index.ts +1 -1
- package/src/utils/request/request.test.ts +26 -26
- package/src/utils/request/request.ts +48 -48
- package/src/utils/semverCompare/index.ts +1 -1
- package/src/utils/semverCompare/semverCompare.test.ts +49 -49
- package/src/utils/semverCompare/semverCompare.ts +60 -60
- package/src/utils/sendEmail/index.ts +1 -1
- package/src/utils/sendEmail/sendEmail.ts +27 -27
- package/src/utils/sendEmail/sendEmail.types.ts +7 -7
- package/src/utils/sendPush/index.ts +2 -2
- package/src/utils/sendPush/sendPush.ts +20 -20
- package/src/utils/sendPush/sendPush.types.ts +25 -25
- package/src/utils/tlsConfig/index.ts +2 -2
- package/src/utils/tlsConfig/tlsConfig.test.ts +32 -32
- package/src/utils/tlsConfig/tlsConfig.ts +47 -47
- package/src/utils/tlsConfig/tlsConfig.types.ts +11 -11
- package/src/utils/tlsConfig/tlsConfig.validate.ts +25 -25
- package/src/utils/tlsRequest/index.ts +1 -1
- package/src/utils/tlsRequest/tlsRequest.test.ts +63 -63
- package/src/utils/tlsRequest/tlsRequest.ts +12 -12
- package/src/utils/trimPathSlash/index.ts +1 -1
- package/src/utils/trimPathSlash/trimPathSlash.test.ts +26 -26
- package/src/utils/trimPathSlash/trimPathSlash.ts +8 -8
- package/test/env.ts +56 -56
- package/test/factory/index.ts +8 -8
- package/test/factory/sequelizeMeta.ts +12 -12
- package/test/hooks.ts +37 -37
- package/test/index.ts +3 -3
- package/test/stub/index.ts +3 -3
- package/test/stub/stubLocales.ts +68 -68
- package/test/stub/stubPubSub.ts +7 -7
- package/test/stub/stubStorage.ts +77 -77
- package/test/stub/stubStorage.types.ts +11 -11
- package/test/utils/app.ts +31 -31
- package/test/utils/index.ts +1 -1
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +32 -32
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.validateRedisEnvironment = validateRedisEnvironment;
|
|
7
7
|
var _EngineError = require("../EngineError");
|
|
8
|
-
/**
|
|
9
|
-
* Verify that the environment variables to connect to a Redis server are properly set
|
|
8
|
+
/**
|
|
9
|
+
* Verify that the environment variables to connect to a Redis server are properly set
|
|
10
10
|
*/
|
|
11
11
|
function validateRedisEnvironment(options) {
|
|
12
12
|
const host = process.env.REDIS_HOST ?? options.redis?.host;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Redis.validate.js","names":["_EngineError","require","validateRedisEnvironment","options","host","process","env","REDIS_HOST","redis","EngineError","message","port","REDIS_PORT","parseInt"],"sources":["../../../src/entities/Redis/Redis.validate.ts"],"sourcesContent":["import { RedisCreateOptions } from './Redis.types';\nimport { EngineError } from 'entities/EngineError';\n\n/**\n * Verify that the environment variables to connect to a Redis server are properly set\n */\nexport function validateRedisEnvironment(options: RedisCreateOptions): void {\n const host = process.env.REDIS_HOST ?? options.redis?.host;\n if (typeof host !== 'string')\n throw new EngineError({ message: 'No host specified for Redis instance' });\n\n const port = process.env.REDIS_PORT\n ? parseInt(process.env.REDIS_PORT)\n : options.redis?.port;\n if (typeof port !== 'number')\n throw new EngineError({ message: 'No port specified for Redis instance' });\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,SAASC,wBAAwBA,CAACC,OAA2B,EAAQ;EAC1E,MAAMC,IAAI,GAAGC,OAAO,CAACC,GAAG,CAACC,UAAU,IAAIJ,OAAO,CAACK,KAAK,EAAEJ,IAAI;EAC1D,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAC1B,MAAM,IAAIK,wBAAW,CAAC;IAAEC,OAAO,EAAE;EAAuC,CAAC,CAAC;EAE5E,MAAMC,IAAI,GAAGN,OAAO,CAACC,GAAG,CAACM,UAAU,GAC/BC,QAAQ,CAACR,OAAO,CAACC,GAAG,CAACM,UAAU,CAAC,GAChCT,OAAO,CAACK,KAAK,EAAEG,IAAI;EACvB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAC1B,MAAM,IAAIF,wBAAW,CAAC;IAAEC,OAAO,EAAE;EAAuC,CAAC,CAAC;AAC9E","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Redis.validate.js","names":["_EngineError","require","validateRedisEnvironment","options","host","process","env","REDIS_HOST","redis","EngineError","message","port","REDIS_PORT","parseInt"],"sources":["../../../src/entities/Redis/Redis.validate.ts"],"sourcesContent":["import { RedisCreateOptions } from './Redis.types';\r\nimport { EngineError } from 'entities/EngineError';\r\n\r\n/**\r\n * Verify that the environment variables to connect to a Redis server are properly set\r\n */\r\nexport function validateRedisEnvironment(options: RedisCreateOptions): void {\r\n const host = process.env.REDIS_HOST ?? options.redis?.host;\r\n if (typeof host !== 'string')\r\n throw new EngineError({ message: 'No host specified for Redis instance' });\r\n\r\n const port = process.env.REDIS_PORT\r\n ? parseInt(process.env.REDIS_PORT)\r\n : options.redis?.port;\r\n if (typeof port !== 'number')\r\n throw new EngineError({ message: 'No port specified for Redis instance' });\r\n}\r\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACO,SAASC,wBAAwBA,CAACC,OAA2B,EAAQ;EAC1E,MAAMC,IAAI,GAAGC,OAAO,CAACC,GAAG,CAACC,UAAU,IAAIJ,OAAO,CAACK,KAAK,EAAEJ,IAAI;EAC1D,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAC1B,MAAM,IAAIK,wBAAW,CAAC;IAAEC,OAAO,EAAE;EAAuC,CAAC,CAAC;EAE5E,MAAMC,IAAI,GAAGN,OAAO,CAACC,GAAG,CAACM,UAAU,GAC/BC,QAAQ,CAACR,OAAO,CAACC,GAAG,CAACM,UAAU,CAAC,GAChCT,OAAO,CAACK,KAAK,EAAEG,IAAI;EACvB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAC1B,MAAM,IAAIF,wBAAW,CAAC;IAAEC,OAAO,EAAE;EAAuC,CAAC,CAAC;AAC9E","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Redis","require","_Redis2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../../src/entities/Redis/index.ts"],"sourcesContent":["export { Redis, createRedisClient } from './Redis';\nexport * from './Redis.types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Redis","require","_Redis2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../../src/entities/Redis/index.ts"],"sourcesContent":["export { Redis, createRedisClient } from './Redis';\r\nexport * from './Redis.types';\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -13,17 +13,57 @@ const config = {
|
|
|
13
13
|
database: process.env.SQL_DB,
|
|
14
14
|
host: process.env.SQL_HOST,
|
|
15
15
|
port: process.env.SQL_PORT ? parseInt(process.env.SQL_PORT) : 5432,
|
|
16
|
+
// Default port for PostgreSQL
|
|
16
17
|
dialect: process.env.SQL_TYPE ?? 'postgres',
|
|
18
|
+
// Dynamically set the dialect (postgres, mysql, mssql)
|
|
17
19
|
logging: false,
|
|
20
|
+
// Set to true for debugging SQL queries
|
|
18
21
|
define: {
|
|
19
22
|
freezeTableName: false,
|
|
23
|
+
// Prevent automatic pluralization of table names
|
|
20
24
|
charset: 'utf8mb4',
|
|
21
|
-
|
|
25
|
+
// Set character set for MySQL/MariaDB
|
|
26
|
+
collate: 'utf8mb4_unicode_ci' // Set collation for MySQL/MariaDB
|
|
22
27
|
},
|
|
23
28
|
retry: {
|
|
24
|
-
max: 5
|
|
29
|
+
max: 5 // Maximum retry attempts for failed queries
|
|
30
|
+
},
|
|
31
|
+
dialectOptions: {},
|
|
32
|
+
pool: {
|
|
33
|
+
max: 5,
|
|
34
|
+
min: 0,
|
|
35
|
+
acquire: 30000,
|
|
36
|
+
// Maximum time to wait for a connection
|
|
37
|
+
idle: 10000 // Maximum idle time for connections
|
|
25
38
|
}
|
|
26
39
|
};
|
|
40
|
+
|
|
41
|
+
// Additional configurations for MSSQL
|
|
42
|
+
if (config.dialect === 'mssql') {
|
|
43
|
+
config.dialectOptions = {
|
|
44
|
+
requestTimeout: 30000,
|
|
45
|
+
// Increase request timeout for MSSQL
|
|
46
|
+
connectTimeout: 30000,
|
|
47
|
+
// Increase connection timeout for MSSQL
|
|
48
|
+
encrypt: true,
|
|
49
|
+
// Use encryption for MSSQL (set to false if not needed)
|
|
50
|
+
trustServerCertificate: true // Set to true if using self-signed certificates
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add specific dialect configurations if necessary for MySQL/PostgreSQL
|
|
55
|
+
if (config.dialect === 'mysql') {
|
|
56
|
+
config.dialectOptions = {
|
|
57
|
+
timezone: 'Z' // Set timezone for MySQL
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (config.dialect === 'postgres') {
|
|
61
|
+
config.dialectOptions = {
|
|
62
|
+
ssl: process.env.PG_SSL === 'true' ? {
|
|
63
|
+
rejectUnauthorized: false
|
|
64
|
+
} : false // SSL options for PostgreSQL (if required)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
27
67
|
const development = exports.development = config;
|
|
28
68
|
const staging = exports.staging = config;
|
|
29
69
|
const production = exports.production = config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.config.js","names":["_Sequelize","require","validateSequelizeEnvironment","config","username","process","env","SQL_USER","password","SQL_PASSWORD","database","SQL_DB","host","SQL_HOST","port","SQL_PORT","parseInt","dialect","SQL_TYPE","logging","define","freezeTableName","charset","collate","retry","max","development","exports","staging","production","test","_default","default"],"sources":["../../../src/entities/Sequelize/Sequelize.config.ts"],"sourcesContent":["import { Options, Dialect } from 'sequelize';\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\n\n// Check that environment variables are correctly set\nvalidateSequelizeEnvironment();\n\nconst config: Options = {\n username: process.env.SQL_USER,\n password: process.env.SQL_PASSWORD,\n database: process.env.SQL_DB,\n host: process.env.SQL_HOST,\n port: process.env.SQL_PORT ? parseInt(process.env.SQL_PORT) : 5432
|
|
1
|
+
{"version":3,"file":"Sequelize.config.js","names":["_Sequelize","require","validateSequelizeEnvironment","config","username","process","env","SQL_USER","password","SQL_PASSWORD","database","SQL_DB","host","SQL_HOST","port","SQL_PORT","parseInt","dialect","SQL_TYPE","logging","define","freezeTableName","charset","collate","retry","max","dialectOptions","pool","min","acquire","idle","requestTimeout","connectTimeout","encrypt","trustServerCertificate","timezone","ssl","PG_SSL","rejectUnauthorized","development","exports","staging","production","test","_default","default"],"sources":["../../../src/entities/Sequelize/Sequelize.config.ts"],"sourcesContent":["import { Options, Dialect } from 'sequelize';\r\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\r\n\r\n// Check that environment variables are correctly set\r\nvalidateSequelizeEnvironment();\r\n\r\nconst config: Options = {\r\n username: process.env.SQL_USER,\r\n password: process.env.SQL_PASSWORD,\r\n database: process.env.SQL_DB,\r\n host: process.env.SQL_HOST,\r\n port: process.env.SQL_PORT ? parseInt(process.env.SQL_PORT) : 5432, // Default port for PostgreSQL\r\n dialect: (process.env.SQL_TYPE ?? 'postgres') as Dialect, // Dynamically set the dialect (postgres, mysql, mssql)\r\n logging: false, // Set to true for debugging SQL queries\r\n define: {\r\n freezeTableName: false, // Prevent automatic pluralization of table names\r\n charset: 'utf8mb4', // Set character set for MySQL/MariaDB\r\n collate: 'utf8mb4_unicode_ci' // Set collation for MySQL/MariaDB\r\n },\r\n retry: {\r\n max: 5 // Maximum retry attempts for failed queries\r\n },\r\n dialectOptions: {},\r\n pool: {\r\n max: 5,\r\n min: 0,\r\n acquire: 30000, // Maximum time to wait for a connection\r\n idle: 10000 // Maximum idle time for connections\r\n },\r\n};\r\n\r\n// Additional configurations for MSSQL\r\nif (config.dialect === 'mssql') {\r\n config.dialectOptions = {\r\n requestTimeout: 30000, // Increase request timeout for MSSQL\r\n connectTimeout: 30000, // Increase connection timeout for MSSQL\r\n encrypt: true, // Use encryption for MSSQL (set to false if not needed)\r\n trustServerCertificate: true, // Set to true if using self-signed certificates\r\n };\r\n}\r\n\r\n// Add specific dialect configurations if necessary for MySQL/PostgreSQL\r\nif (config.dialect === 'mysql') {\r\n config.dialectOptions = {\r\n timezone: 'Z', // Set timezone for MySQL\r\n };\r\n}\r\n\r\nif (config.dialect === 'postgres') {\r\n config.dialectOptions = {\r\n ssl: process.env.PG_SSL === 'true' ? { rejectUnauthorized: false } : false, // SSL options for PostgreSQL (if required)\r\n };\r\n}\r\n\r\nexport const development = config;\r\nexport const staging = config;\r\nexport const production = config;\r\nexport const test = config;\r\nexport default config;\r\n"],"mappings":";;;;;;AACA,IA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AAE,GAAG,CAAE;EACjB,CAAC;AACH;AAEA,IAAIhC,MAAM,CAACc,OAAO,KAAK,UAAU,EAAE;EACjCd,MAAM,CAACuB,cAAc,GAAG;IACtBU,GAAG,EAAE/B,OAAO,CAACC,GAAG,CAAC+B,MAAM,KAAK,MAAM,GAAG;MAAEC,kBAAkB,EAAE;IAAM,CAAC,GAAG,KAAK,CAAE;EAC9E,CAAC;AACH;AAEO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGpC,MAAM;AAC1B,MAAMsC,OAAO,GAAAD,OAAA,CAAAC,OAAA,GAAGtC,MAAM;AACtB,MAAMuC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAGvC,MAAM;AACzB,MAAMwC,IAAI,GAAAH,OAAA,CAAAG,IAAA,GAAGxC,MAAM;AAAC,IAAAyC,QAAA,GAAAJ,OAAA,CAAAK,OAAA,GACZ1C,MAAM","ignoreList":[]}
|
|
@@ -16,8 +16,8 @@ var _EngineError = require("../EngineError");
|
|
|
16
16
|
var _LifecycleController = require("../LifecycleController");
|
|
17
17
|
let sequelizeClient = exports.sequelizeClient = void 0;
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* We use a proxy to extend the Sequelize behavior and allow initialization of the client only when needed while keeping the same interface
|
|
19
|
+
/**
|
|
20
|
+
* We use a proxy to extend the Sequelize behavior and allow initialization of the client only when needed while keeping the same interface
|
|
21
21
|
*/
|
|
22
22
|
const sequelize = exports.sequelize = new Proxy(
|
|
23
23
|
// Due to how we do the proxying, we are forced to ignore ts-errors, we could never create an object that respects the interface properly
|
|
@@ -44,7 +44,7 @@ function init() {
|
|
|
44
44
|
// Ignore if already initialized
|
|
45
45
|
if (sequelizeClient) return;
|
|
46
46
|
exports.sequelizeClient = sequelizeClient = createSequelizeClient();
|
|
47
|
-
sequelizeClient.authenticate().then(() => console.log('Connected to
|
|
47
|
+
sequelizeClient.authenticate().then(() => console.log('Connected to database.')).catch(err => console.error('Unable to connect to the database:', err));
|
|
48
48
|
_LifecycleController.LifecycleController.register(sequelize);
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.js","names":["_sequelizeTypescript","require","_Sequelize","_interopRequireDefault","_Sequelize2","_EngineError","_LifecycleController","sequelizeClient","exports","sequelize","Proxy","get","target","property","init","shutdown","addModels","EngineError","message","createSequelizeClient","authenticate","then","console","log","catch","err","error","LifecycleController","register","close","undefined","models","sync","validateSequelizeEnvironment","Sequelize","process","env","SQL_DB","SQL_USER","SQL_PASSWORD","dbConfig"],"sources":["../../../src/entities/Sequelize/Sequelize.ts"],"sourcesContent":["import { Sequelize, ModelCtor } from 'sequelize-typescript';\nimport dbConfig from './Sequelize.config';\nimport { Sequelize as SequelizeInterface } from './Sequelize.types';\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\n\nexport let sequelizeClient: undefined | Sequelize;\n\n/**\n * We use a proxy to extend the Sequelize behavior and allow initialization of the client only when needed while keeping the same interface\n */\nexport const sequelize = new Proxy<SequelizeInterface>(\n // Due to how we do the proxying, we are forced to ignore ts-errors, we could never create an object that respects the interface properly\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n {},\n {\n get: function (target, property): unknown {\n if (property === 'init') return init;\n if (property === 'shutdown') return shutdown;\n if (property === 'addModels') return addModels;\n // Create the sequelize client if it does not exist\n if (!sequelizeClient)\n throw new EngineError({\n message: 'Sequelize client was not initialized'\n });\n // Call the function on the sequelize client\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return sequelizeClient[property] as unknown;\n }\n }\n);\n\n/** On init create client and connect */\nexport function init(): void {\n // Ignore if already initialized\n if (sequelizeClient) return;\n sequelizeClient = createSequelizeClient();\n sequelizeClient\n .authenticate()\n .then(() => console.log('Connected to
|
|
1
|
+
{"version":3,"file":"Sequelize.js","names":["_sequelizeTypescript","require","_Sequelize","_interopRequireDefault","_Sequelize2","_EngineError","_LifecycleController","sequelizeClient","exports","sequelize","Proxy","get","target","property","init","shutdown","addModels","EngineError","message","createSequelizeClient","authenticate","then","console","log","catch","err","error","LifecycleController","register","close","undefined","models","sync","validateSequelizeEnvironment","Sequelize","process","env","SQL_DB","SQL_USER","SQL_PASSWORD","dbConfig"],"sources":["../../../src/entities/Sequelize/Sequelize.ts"],"sourcesContent":["import { Sequelize, ModelCtor } from 'sequelize-typescript';\r\nimport dbConfig from './Sequelize.config';\r\nimport { Sequelize as SequelizeInterface } from './Sequelize.types';\r\nimport { validateSequelizeEnvironment } from './Sequelize.validate';\r\nimport { EngineError } from 'entities/EngineError';\r\nimport { LifecycleController } from 'entities/LifecycleController';\r\n\r\nexport let sequelizeClient: undefined | Sequelize;\r\n\r\n/**\r\n * We use a proxy to extend the Sequelize behavior and allow initialization of the client only when needed while keeping the same interface\r\n */\r\nexport const sequelize = new Proxy<SequelizeInterface>(\r\n // Due to how we do the proxying, we are forced to ignore ts-errors, we could never create an object that respects the interface properly\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n {},\r\n {\r\n get: function (target, property): unknown {\r\n if (property === 'init') return init;\r\n if (property === 'shutdown') return shutdown;\r\n if (property === 'addModels') return addModels;\r\n // Create the sequelize client if it does not exist\r\n if (!sequelizeClient)\r\n throw new EngineError({\r\n message: 'Sequelize client was not initialized'\r\n });\r\n // Call the function on the sequelize client\r\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\r\n // @ts-ignore\r\n return sequelizeClient[property] as unknown;\r\n }\r\n }\r\n);\r\n\r\n/** On init create client and connect */\r\nexport function init(): void {\r\n // Ignore if already initialized\r\n if (sequelizeClient) return;\r\n sequelizeClient = createSequelizeClient();\r\n sequelizeClient\r\n .authenticate()\r\n .then(() => console.log('Connected to database.'))\r\n .catch((err: Error) =>\r\n console.error('Unable to connect to the database:', err)\r\n );\r\n LifecycleController.register(sequelize);\r\n}\r\n\r\n/** On shutdown close connection and clear client */\r\nexport async function shutdown(): Promise<void> {\r\n if (sequelizeClient) await sequelizeClient.close();\r\n sequelizeClient = undefined;\r\n}\r\n\r\nexport function addModels(models: Array<ModelCtor>): void {\r\n if (!sequelizeClient)\r\n throw new EngineError({\r\n message: 'Sequelize client was not initialized'\r\n });\r\n sequelizeClient.addModels(models);\r\n sequelizeClient.sync();\r\n}\r\n\r\n/** Create Sequelize client */\r\nexport function createSequelizeClient(): Sequelize {\r\n // Throw an error if there is no host initial\r\n validateSequelizeEnvironment();\r\n return new Sequelize(\r\n process.env.SQL_DB as string,\r\n process.env.SQL_USER as string,\r\n process.env.SQL_PASSWORD as string,\r\n dbConfig\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEO,IAAIM,eAAsC,GAAAC,OAAA,CAAAD,eAAA;;AAEjD;AACA;AACA;AACO,MAAME,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG,IAAIC,KAAK;AAChC;AACA;AACA;AACA,CAAC,CAAC,EACF;EACEC,GAAG,EAAE,SAAAA,CAAUC,MAAM,EAAEC,QAAQ,EAAW;IACxC,IAAIA,QAAQ,KAAK,MAAM,EAAE,OAAOC,IAAI;IACpC,IAAID,QAAQ,KAAK,UAAU,EAAE,OAAOE,QAAQ;IAC5C,IAAIF,QAAQ,KAAK,WAAW,EAAE,OAAOG,SAAS;IAC9C;IACA,IAAI,CAACT,eAAe,EAClB,MAAM,IAAIU,wBAAW,CAAC;MACpBC,OAAO,EAAE;IACX,CAAC,CAAC;IACJ;IACA;IACA;IACA,OAAOX,eAAe,CAACM,QAAQ,CAAC;EAClC;AACF,CACF,CAAC;;AAED;AACO,SAASC,IAAIA,CAAA,EAAS;EAC3B;EACA,IAAIP,eAAe,EAAE;EACrBC,OAAA,CAAAD,eAAA,GAAAA,eAAe,GAAGY,qBAAqB,CAAC,CAAC;EACzCZ,eAAe,CACZa,YAAY,CAAC,CAAC,CACdC,IAAI,CAAC,MAAMC,OAAO,CAACC,GAAG,CAAC,wBAAwB,CAAC,CAAC,CACjDC,KAAK,CAAEC,GAAU,IAChBH,OAAO,CAACI,KAAK,CAAC,oCAAoC,EAAED,GAAG,CACzD,CAAC;EACHE,wCAAmB,CAACC,QAAQ,CAACnB,SAAS,CAAC;AACzC;;AAEA;AACO,eAAeM,QAAQA,CAAA,EAAkB;EAC9C,IAAIR,eAAe,EAAE,MAAMA,eAAe,CAACsB,KAAK,CAAC,CAAC;EAClDrB,OAAA,CAAAD,eAAA,GAAAA,eAAe,GAAGuB,SAAS;AAC7B;AAEO,SAASd,SAASA,CAACe,MAAwB,EAAQ;EACxD,IAAI,CAACxB,eAAe,EAClB,MAAM,IAAIU,wBAAW,CAAC;IACpBC,OAAO,EAAE;EACX,CAAC,CAAC;EACJX,eAAe,CAACS,SAAS,CAACe,MAAM,CAAC;EACjCxB,eAAe,CAACyB,IAAI,CAAC,CAAC;AACxB;;AAEA;AACO,SAASb,qBAAqBA,CAAA,EAAc;EACjD;EACA,IAAAc,wCAA4B,EAAC,CAAC;EAC9B,OAAO,IAAIC,8BAAS,CAClBC,OAAO,CAACC,GAAG,CAACC,MAAM,EAClBF,OAAO,CAACC,GAAG,CAACE,QAAQ,EACpBH,OAAO,CAACC,GAAG,CAACG,YAAY,EACxBC,kBACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.types.js","names":[],"sources":["../../../src/entities/Sequelize/Sequelize.types.ts"],"sourcesContent":["import { Sequelize as SequelizeClass, ModelCtor } from 'sequelize-typescript';\n\nexport type Sequelize = SequelizeClass & {\n /** Start the sequelize service */\n init: () => void;\n /** Stop the sequelize service */\n shutdown: () => Promise<void>;\n /** Register a model with sequelize */\n addModels: (models: Array<ModelCtor>) => void;\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Sequelize.types.js","names":[],"sources":["../../../src/entities/Sequelize/Sequelize.types.ts"],"sourcesContent":["import { Sequelize as SequelizeClass, ModelCtor } from 'sequelize-typescript';\r\n\r\nexport type Sequelize = SequelizeClass & {\r\n /** Start the sequelize service */\r\n init: () => void;\r\n /** Stop the sequelize service */\r\n shutdown: () => Promise<void>;\r\n /** Register a model with sequelize */\r\n addModels: (models: Array<ModelCtor>) => void;\r\n};\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.validateSequelizeEnvironment = validateSequelizeEnvironment;
|
|
7
7
|
var _checkEnvironment = require("../../utils/checkEnvironment");
|
|
8
8
|
var _envAssert = require("../../utils/envAssert");
|
|
9
|
-
/**
|
|
10
|
-
* Verify that the environment variables to connect to a SQL server are properly set
|
|
9
|
+
/**
|
|
10
|
+
* Verify that the environment variables to connect to a SQL server are properly set
|
|
11
11
|
*/
|
|
12
12
|
function validateSequelizeEnvironment() {
|
|
13
13
|
// We only check if there is at least the host specified
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sequelize.validate.js","names":["_checkEnvironment","require","_envAssert","validateSequelizeEnvironment","process","env","SQL_HOST","assertEnvironment","envAssert","isHost","SQL_PASSWORD","isString","SQL_DB","SQL_USER"],"sources":["../../../src/entities/Sequelize/Sequelize.validate.ts"],"sourcesContent":["import { assertEnvironment } from 'utils/checkEnvironment';\nimport { envAssert } from 'utils/envAssert';\n\n/**\n * Verify that the environment variables to connect to a SQL server are properly set\n */\nexport function validateSequelizeEnvironment(): void {\n // We only check if there is at least the host specified\n if (process.env.SQL_HOST) assertEnvironment({ SQL_HOST: envAssert.isHost() });\n if (process.env.SQL_PASSWORD)\n assertEnvironment({ SQL_PASSWORD: envAssert.isString() });\n if (process.env.SQL_DB) assertEnvironment({ SQL_DB: envAssert.isString() });\n if (process.env.SQL_USER)\n assertEnvironment({ SQL_USER: envAssert.isString() });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,SAASE,4BAA4BA,CAAA,EAAS;EACnD;EACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE,IAAAC,mCAAiB,EAAC;IAAED,QAAQ,EAAEE,oBAAS,CAACC,MAAM,CAAC;EAAE,CAAC,CAAC;EAC7E,IAAIL,OAAO,CAACC,GAAG,CAACK,YAAY,EAC1B,IAAAH,mCAAiB,EAAC;IAAEG,YAAY,EAAEF,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;EAC3D,IAAIP,OAAO,CAACC,GAAG,CAACO,MAAM,EAAE,IAAAL,mCAAiB,EAAC;IAAEK,MAAM,EAAEJ,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;EAC3E,IAAIP,OAAO,CAACC,GAAG,CAACQ,QAAQ,EACtB,IAAAN,mCAAiB,EAAC;IAAEM,QAAQ,EAAEL,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;AACzD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Sequelize.validate.js","names":["_checkEnvironment","require","_envAssert","validateSequelizeEnvironment","process","env","SQL_HOST","assertEnvironment","envAssert","isHost","SQL_PASSWORD","isString","SQL_DB","SQL_USER"],"sources":["../../../src/entities/Sequelize/Sequelize.validate.ts"],"sourcesContent":["import { assertEnvironment } from 'utils/checkEnvironment';\r\nimport { envAssert } from 'utils/envAssert';\r\n\r\n/**\r\n * Verify that the environment variables to connect to a SQL server are properly set\r\n */\r\nexport function validateSequelizeEnvironment(): void {\r\n // We only check if there is at least the host specified\r\n if (process.env.SQL_HOST) assertEnvironment({ SQL_HOST: envAssert.isHost() });\r\n if (process.env.SQL_PASSWORD)\r\n assertEnvironment({ SQL_PASSWORD: envAssert.isString() });\r\n if (process.env.SQL_DB) assertEnvironment({ SQL_DB: envAssert.isString() });\r\n if (process.env.SQL_USER)\r\n assertEnvironment({ SQL_USER: envAssert.isString() });\r\n}\r\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACO,SAASE,4BAA4BA,CAAA,EAAS;EACnD;EACA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAE,IAAAC,mCAAiB,EAAC;IAAED,QAAQ,EAAEE,oBAAS,CAACC,MAAM,CAAC;EAAE,CAAC,CAAC;EAC7E,IAAIL,OAAO,CAACC,GAAG,CAACK,YAAY,EAC1B,IAAAH,mCAAiB,EAAC;IAAEG,YAAY,EAAEF,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;EAC3D,IAAIP,OAAO,CAACC,GAAG,CAACO,MAAM,EAAE,IAAAL,mCAAiB,EAAC;IAAEK,MAAM,EAAEJ,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;EAC3E,IAAIP,OAAO,CAACC,GAAG,CAACQ,QAAQ,EACtB,IAAAN,mCAAiB,EAAC;IAAEM,QAAQ,EAAEL,oBAAS,CAACG,QAAQ,CAAC;EAAE,CAAC,CAAC;AACzD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Sequelize","require","_Sequelize2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../../src/entities/Sequelize/index.ts"],"sourcesContent":["export { sequelize } from './Sequelize';\nexport * from './Sequelize.types';\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Sequelize","require","_Sequelize2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["../../../src/entities/Sequelize/index.ts"],"sourcesContent":["export { sequelize } from './Sequelize';\r\nexport * from './Sequelize.types';\r\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.const.js","names":["_express","require","_morgan","_interopRequireDefault","_middleware","ACCESS_LOG","JSON","stringify","method","status","url","ip","referrer","severity","message","defaultMiddleware","exports","healthCheck","json","limit","process","env","REQUEST_SIZE_LIMIT","urlencoded","extended","metrics","version","filter","val","defaultErrorMiddleware","error","fourOhFour","secondaryMiddleware","swaggerDocs","SILENCE_REPORT","unshift","morgan","shutdownSignals"],"sources":["../../../src/entities/Server/Server.const.ts"],"sourcesContent":["import { json, urlencoded, ErrorRequestHandler, RequestHandler } from 'express';\nimport morgan from 'morgan';\nimport {\n metrics,\n error,\n fourOhFour,\n healthCheck,\n version,\n swaggerDocs\n} from 'middleware';\n\nconst ACCESS_LOG = JSON.stringify({\n method: ':method',\n status: ':status',\n url: ':url',\n 'http-version': ':http-version',\n ip: ':remote-addr',\n 'user-agent': ':user-agent',\n 'content-length': ':res[content-length]',\n referrer: ':referrer',\n 'response-time': ':response-time',\n severity: 'DEBUG',\n message: ':method :url [:status]'\n});\n\n// Default middleware that are applied first thing on the primary port, before the business logic endpoints\nexport const defaultMiddleware: Array<RequestHandler> = [\n healthCheck(),\n json({ limit: process.env.REQUEST_SIZE_LIMIT ?? '1mb' }),\n urlencoded({\n extended: true,\n limit: process.env.REQUEST_SIZE_LIMIT ?? '1mb'\n }),\n metrics(),\n version()\n].filter((val) => val);\n\n// Error handling middleware that are run after the main business logic endpoints\nexport const defaultErrorMiddleware: Array<\n RequestHandler | ErrorRequestHandler\n> = [error, fourOhFour];\n\n// Middleware that are served on the secondary port\nexport const secondaryMiddleware: Array<RequestHandler> = [\n metrics(),\n version(),\n swaggerDocs()\n];\n\n// Add morgan logging to default middleware chain when reporting is not silenced\nif (!process.env.SILENCE_REPORT) {\n defaultMiddleware.unshift(morgan(ACCESS_LOG));\n secondaryMiddleware.unshift(morgan(ACCESS_LOG));\n}\n\nexport const shutdownSignals = ['SIGTERM', 'SIGUSR2', 'SIGINT'];\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,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AU,CAAC,CAAC;AACjD;AAEO,MAAMgC,eAAe,GAAArB,OAAA,CAAAqB,eAAA,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Server.const.js","names":["_express","require","_morgan","_interopRequireDefault","_middleware","ACCESS_LOG","JSON","stringify","method","status","url","ip","referrer","severity","message","defaultMiddleware","exports","healthCheck","json","limit","process","env","REQUEST_SIZE_LIMIT","urlencoded","extended","metrics","version","filter","val","defaultErrorMiddleware","error","fourOhFour","secondaryMiddleware","swaggerDocs","SILENCE_REPORT","unshift","morgan","shutdownSignals"],"sources":["../../../src/entities/Server/Server.const.ts"],"sourcesContent":["import { json, urlencoded, ErrorRequestHandler, RequestHandler } from 'express';\r\nimport morgan from 'morgan';\r\nimport {\r\n metrics,\r\n error,\r\n fourOhFour,\r\n healthCheck,\r\n version,\r\n swaggerDocs\r\n} from 'middleware';\r\n\r\nconst ACCESS_LOG = JSON.stringify({\r\n method: ':method',\r\n status: ':status',\r\n url: ':url',\r\n 'http-version': ':http-version',\r\n ip: ':remote-addr',\r\n 'user-agent': ':user-agent',\r\n 'content-length': ':res[content-length]',\r\n referrer: ':referrer',\r\n 'response-time': ':response-time',\r\n severity: 'DEBUG',\r\n message: ':method :url [:status]'\r\n});\r\n\r\n// Default middleware that are applied first thing on the primary port, before the business logic endpoints\r\nexport const defaultMiddleware: Array<RequestHandler> = [\r\n healthCheck(),\r\n json({ limit: process.env.REQUEST_SIZE_LIMIT ?? '1mb' }),\r\n urlencoded({\r\n extended: true,\r\n limit: process.env.REQUEST_SIZE_LIMIT ?? '1mb'\r\n }),\r\n metrics(),\r\n version()\r\n].filter((val) => val);\r\n\r\n// Error handling middleware that are run after the main business logic endpoints\r\nexport const defaultErrorMiddleware: Array<\r\n RequestHandler | ErrorRequestHandler\r\n> = [error, fourOhFour];\r\n\r\n// Middleware that are served on the secondary port\r\nexport const secondaryMiddleware: Array<RequestHandler> = [\r\n metrics(),\r\n version(),\r\n swaggerDocs()\r\n];\r\n\r\n// Add morgan logging to default middleware chain when reporting is not silenced\r\nif (!process.env.SILENCE_REPORT) {\r\n defaultMiddleware.unshift(morgan(ACCESS_LOG));\r\n secondaryMiddleware.unshift(morgan(ACCESS_LOG));\r\n}\r\n\r\nexport const shutdownSignals = ['SIGTERM', 'SIGUSR2', 'SIGINT'];\r\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AASA,MAAMI,UAAU,GAAGC,IAAI,CAACC,SAAS,CAAC;EAChCC,MAAM,EAAE,SAAS;EACjBC,MAAM,EAAE,SAAS;EACjBC,GAAG,EAAE,MAAM;EACX,cAAc,EAAE,eAAe;EAC/BC,EAAE,EAAE,cAAc;EAClB,YAAY,EAAE,aAAa;EAC3B,gBAAgB,EAAE,sBAAsB;EACxCC,QAAQ,EAAE,WAAW;EACrB,eAAe,EAAE,gBAAgB;EACjCC,QAAQ,EAAE,OAAO;EACjBC,OAAO,EAAE;AACX,CAAC,CAAC;;AAEF;AACO,MAAMC,iBAAwC,GAAAC,OAAA,CAAAD,iBAAA,GAAG,CACtD,IAAAE,uBAAW,EAAC,CAAC,EACb,IAAAC,aAAI,EAAC;EAAEC,KAAK,EAAEC,OAAO,CAACC,GAAG,CAACC,kBAAkB,IAAI;AAAM,CAAC,CAAC,EACxD,IAAAC,mBAAU,EAAC;EACTC,QAAQ,EAAE,IAAI;EACdL,KAAK,EAAEC,OAAO,CAACC,GAAG,CAACC,kBAAkB,IAAI;AAC3C,CAAC,CAAC,EACF,IAAAG,mBAAO,EAAC,CAAC,EACT,IAAAC,mBAAO,EAAC,CAAC,CACV,CAACC,MAAM,CAAEC,GAAG,IAAKA,GAAG,CAAC;;AAEtB;AACO,MAAMC,sBAEZ,GAAAb,OAAA,CAAAa,sBAAA,GAAG,CAACC,iBAAK,EAAEC,sBAAU,CAAC;;AAEvB;AACO,MAAMC,mBAA0C,GAAAhB,OAAA,CAAAgB,mBAAA,GAAG,CACxD,IAAAP,mBAAO,EAAC,CAAC,EACT,IAAAC,mBAAO,EAAC,CAAC,EACT,IAAAO,uBAAW,EAAC,CAAC,CACd;;AAED;AACA,IAAI,CAACb,OAAO,CAACC,GAAG,CAACa,cAAc,EAAE;EAC/BnB,iBAAiB,CAACoB,OAAO,CAAC,IAAAC,eAAM,EAAC/B,UAAU,CAAC,CAAC;EAC7C2B,mBAAmB,CAACG,OAAO,CAAC,IAAAC,eAAM,EAAC/B,UAAU,CAAC,CAAC;AACjD;AAEO,MAAMgC,eAAe,GAAArB,OAAA,CAAAqB,eAAA,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -364,8 +364,8 @@ let Server = exports.Server = /*#__PURE__*/function () {
|
|
|
364
364
|
return typeof callback === 'function' ? callback() : callback.function.apply(null, callback.parameters ?? []);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
/**
|
|
368
|
-
* Validate the Server constructor configuration
|
|
367
|
+
/**
|
|
368
|
+
* Validate the Server constructor configuration
|
|
369
369
|
*/
|
|
370
370
|
}, {
|
|
371
371
|
key: "validate",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","names":["_fs","_interopRequireDefault","require","_path","_promises","_express","_ws","_SocketClient","_Server2","_Endpoint","_EngineError","_LifecycleController","_PubSub","_utils","_jwt","_report","_tlsConfig","namespace","Server","exports","config","_classCallCheck2","default","app","httpServer","secondaryApp","secondaryHttpServer","endpoints","checkEnvironment","globalMiddleware","errorMiddleware","initCallbacks","shutdownCallbacks","syncCallbacks","cron","auth","wss","abortController","AbortController","validate","reportDebug","message","noFetch","process","env","RUN_MIGRATION","UNDO_MIGRATION","SQL_HOST","envAssert","isHost","SQL_USER","isString","SQL_PASSWORD","SQL_DB","NODE_ENV","PORT","isPort","SECONDARY_PORT","express","registerMiddleware","createHttpServer","secondaryMiddleware","defaultErrorMiddleware","forEach","middleware","use","disable","server","headersTimeout","keepAliveTimeout","webSocket","attachWebSocket","_createClass2","key","value","init","initKeySets","callback","runCallback","Promise","all","map","PubSub","job","runCronJob","resolve","listen","reportInfo","data","port","secondaryPort","nodeEnv","handleSignal","watchTlsCaFileChange","shutdown","listening","address","on","error","reportError","exit","close","clients","socket","socketKillTimeout","WEBSOCKET_CLOSE_TIMEOUT","parseInt","setTimeout","readyState","CLOSING","OPEN","terminate","LifecycleController","shutdownRunningInstances","abort","shutdownKeySets","shutdownSignals","signal","removeAllListeners","getApp","getSecondaryApp","defaultMiddleware","path","endpoint","register","options","WebSocketServer","request","SocketClient","client","catch","file","fs","watch","event","loadTlsConfig","setSecureContext","tlsConfig","handler","name","interval","setTimeoutPromise","undefined","Error","function","apply","parameters","some","Endpoint","EngineError","Object","values","validator","Array"],"sources":["../../../src/entities/Server/Server.ts"],"sourcesContent":["import fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport { AddressInfo } from 'net';\nimport path from 'path';\nimport { setTimeout as setTimeoutPromise } from 'timers/promises';\nimport { ValidatorSpec } from 'envalid';\nimport express, { Application } from 'express';\nimport { Server as WebSocketServer } from 'ws';\nimport { SocketClient } from '../SocketClient';\nimport {\n defaultMiddleware,\n defaultErrorMiddleware,\n secondaryMiddleware,\n shutdownSignals\n} from './Server.const';\nimport {\n ServerOptions,\n ServerCronJon,\n ServerAuthConfig,\n ServerWebSocketConfig,\n ServerGlobalMiddleware,\n ServerErrorMiddleWare,\n ServerCallback\n} from './Server.types';\nimport { Endpoint } from 'entities/Endpoint';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { PubSub } from 'entities/PubSub';\nimport { checkEnvironment, envAssert, createHttpServer } from 'utils';\nimport { initKeySets, shutdownKeySets } from 'utils/jwt';\nimport { reportInfo, reportError, reportDebug } from 'utils/report';\nimport { tlsConfig, loadTlsConfig, TlsConfig } from 'utils/tlsConfig';\n\nconst namespace = 'engine:Server';\n\n/** Main server class */\nexport class Server {\n /** The express application powering the main endpoints */\n private app: Application;\n /** The node HTTP(S) server, serving the main express application */\n private httpServer: http.Server | https.Server;\n /** The express application powering the support endpoints */\n private secondaryApp: Application;\n /** The node HTTP(S) server, serving the secondary express application */\n private secondaryHttpServer: http.Server | https.Server;\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n private checkEnvironment: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n private globalMiddleware: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n private errorMiddleware: Array<\n ServerGlobalMiddleware | ServerErrorMiddleWare\n >;\n /** Functions that should be called on server startup */\n private initCallbacks: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n private shutdownCallbacks: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n private syncCallbacks: boolean;\n /** Config to set regularly running jobs on the server */\n private cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n private auth: ServerAuthConfig;\n /** WebSocket server instance, if configured */\n private wss?: WebSocketServer;\n /** Abort controller that handles signals for the server */\n private abortController = new AbortController();\n\n /** Create a server */\n public constructor(config: ServerOptions) {\n this.validate(config);\n\n reportDebug({\n namespace,\n message: `Creating server`\n });\n\n this.endpoints = config.endpoints;\n this.globalMiddleware = config.globalMiddleware ?? [];\n this.errorMiddleware = config.errorMiddleware ?? [];\n this.initCallbacks = config.initCallbacks ?? [];\n this.shutdownCallbacks = config.shutdownCallbacks ?? [];\n this.syncCallbacks = config.syncCallbacks ?? false;\n this.cron = config.cron;\n this.auth = { noFetch: false, ...config.auth };\n\n // The minimal environment check is different between the migration modes of execution and the regular server execution mode\n // When running in migration mode, we only check that we have SQL related environment variables\n this.checkEnvironment =\n process.env.RUN_MIGRATION === 'true' ||\n process.env.UNDO_MIGRATION === 'true'\n ? {\n SQL_HOST: envAssert.isHost(),\n SQL_USER: envAssert.isString(),\n SQL_PASSWORD: envAssert.isString(),\n SQL_DB: envAssert.isString()\n }\n : {\n NODE_ENV: envAssert.isString(),\n PORT: envAssert.isPort(),\n SECONDARY_PORT: envAssert.isPort(),\n ...config.checkEnvironment\n };\n\n checkEnvironment(this.checkEnvironment);\n\n // Create the primary express core that serves the business logic\n this.app = express();\n this.registerMiddleware(this.app);\n this.httpServer = createHttpServer(this.app);\n\n // Create a secondary express core that servers metrics and analytics\n // This will be served on a different port, allowing to specify different firewall rules for these routes\n this.secondaryApp = express();\n [...secondaryMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (middleware) this.secondaryApp.use(middleware);\n }\n );\n this.secondaryHttpServer = createHttpServer(this.secondaryApp);\n\n // Remove the express headers\n this.app.disable('x-powered-by');\n this.secondaryApp.disable('x-powered-by');\n\n // We remove all node timeout on connections and requests\n // This responsibility is delegated to the front-facing load balancer\n [this.httpServer, this.secondaryHttpServer].forEach((server) => {\n server.headersTimeout = 0;\n server.keepAliveTimeout = 0;\n });\n\n if (config.webSocket) {\n this.attachWebSocket(config.webSocket);\n }\n }\n\n /** Start the server */\n public async init(): Promise<void> {\n reportDebug({ namespace, message: `Starting Server` });\n // Fetch the keys for JWT authentication\n // Ignore in test environment as we do symmetrical token signing\n if (process.env.NODE_ENV !== 'test' && !this.auth.noFetch)\n await initKeySets();\n // Run all the init callbacks\n // We can either run them all 1/1 synchronously or run them all in parallel (default)\n // Callback can either be direct function or an object with function and parameters attributes\n\n if (this.syncCallbacks) {\n for (const callback of this.initCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.initCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Initialize the Pub/Sub module\n await PubSub.init();\n // Run all the cronjob\n if (this.cron) {\n this.cron.forEach((job) => {\n this.runCronJob(job);\n });\n }\n\n // Start listening to requests\n await Promise.all([\n new Promise<void>((resolve) =>\n this.httpServer.listen(process.env.PORT, () => {\n resolve();\n })\n ),\n new Promise<void>((resolve) =>\n this.secondaryHttpServer.listen(process.env.SECONDARY_PORT, () => {\n resolve();\n })\n )\n ]);\n reportInfo({\n message: 'SERVER_RUNNING',\n data: {\n port: process.env.PORT,\n secondaryPort: process.env.SECONDARY_PORT,\n nodeEnv: process.env.NODE_ENV\n }\n });\n\n this.handleSignal();\n\n // Watch TSL config files changing\n this.watchTlsCaFileChange();\n }\n\n /** Graceful shutdown */\n public async shutdown(): Promise<void> {\n reportDebug({ namespace, message: `Shutting down Server` });\n\n // Stop listening to HTTP requests\n await Promise.all(\n [this.httpServer, this.secondaryHttpServer].map((server) => {\n // Ignore if the server was already stopped\n // We have observed cases where SIGTERM was thrown multiple times\n if (!server.listening) return;\n const { port } = server.address() as AddressInfo;\n server.on('close', (error: unknown) => {\n if (error) {\n reportError(error);\n process.exit(1);\n } else {\n reportInfo({\n message: `Stopped listening to requests on port ${port}`\n });\n }\n });\n server.close();\n })\n );\n\n // Close all socket connections\n if (this.wss) {\n // First ask then to close gracefully\n this.wss.clients.forEach((socket) => {\n socket.close();\n });\n // Hard terminate all connections still open after a defined time\n const socketKillTimeout = process.env.WEBSOCKET_CLOSE_TIMEOUT\n ? parseInt(process.env.WEBSOCKET_CLOSE_TIMEOUT)\n : 5000;\n await new Promise<void>((resolve) => {\n setTimeout(() => {\n (this.wss as WebSocketServer).clients.forEach((socket) => {\n if (\n socket.readyState === socket.CLOSING ||\n socket.readyState === socket.OPEN\n ) {\n socket.terminate();\n }\n });\n resolve();\n }, socketKillTimeout);\n });\n }\n\n // Run all the shutdown callback\n if (this.syncCallbacks) {\n for (const callback of this.shutdownCallbacks) {\n await this.runCallback(callback);\n }\n } else {\n await Promise.all(\n this.shutdownCallbacks.map((callback) => this.runCallback(callback))\n );\n }\n\n // Shutdown all the running entities\n await LifecycleController.shutdownRunningInstances();\n\n // Abort all the cronjob\n if (this.abortController) this.abortController.abort();\n\n // Stop the keyset timers\n shutdownKeySets();\n\n shutdownSignals.forEach((signal) => process.removeAllListeners(signal));\n }\n\n /** Get the express app instance of the server */\n public getApp(): Application {\n return this.app;\n }\n\n /** Get the express app instance of the server */\n public getSecondaryApp(): Application {\n return this.secondaryApp;\n }\n\n /** Registers all the middleware with the express app */\n private registerMiddleware(app: Application): void {\n // Global middleware can specify a path to which they apply\n [...defaultMiddleware, ...this.globalMiddleware].forEach((middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n });\n // Call the register method of each endpoint\n this.endpoints.forEach((endpoint) => {\n endpoint.register(app);\n });\n // Add error middleware\n [...this.errorMiddleware, ...defaultErrorMiddleware].forEach(\n (middleware) => {\n if (typeof middleware === 'function') {\n app.use(middleware);\n } else {\n app.use(middleware.path, middleware.middleware);\n }\n }\n );\n }\n\n /** Add a handler for WebSocket connections */\n private attachWebSocket(options: ServerWebSocketConfig): void {\n this.wss = new WebSocketServer({\n ...options.server,\n server: this.httpServer\n })\n .on('connection', (webSocket, request) => {\n new SocketClient(webSocket, request, options.client);\n })\n .on('error', (error) => {\n reportError(error);\n });\n }\n\n /** Call shutdown if signal gets sent to the process */\n private handleSignal(): void {\n shutdownSignals.forEach((signal) =>\n process.on(signal, () => {\n (async (): Promise<void> => {\n reportInfo(`Received shutdown signal [${signal}]`);\n await this.shutdown();\n })().catch((error) => {\n reportError(error);\n });\n })\n );\n }\n\n /** Watch the TLS certificate change event */\n private watchTlsCaFileChange(): void {\n [\n 'TLS_REQUEST_KEY',\n 'TLS_REQUEST_KEY_PASSPHRASE',\n 'TLS_REQUEST_CERT',\n 'TLS_REQUEST_CA',\n 'TLS_SERVER_KEY',\n 'TLS_SERVER_KEY_PASSPHRASE',\n 'TLS_SERVER_CERT',\n 'TLS_CA'\n ].forEach((key) => {\n const file = process.env[key];\n if (file)\n fs.watch(path.resolve(file), (event) => {\n if (event !== 'change') return;\n reportInfo(`Reloading TLS config [${file} changed]`);\n loadTlsConfig();\n (this.httpServer as https.Server).setSecureContext(\n tlsConfig as TlsConfig\n );\n });\n });\n }\n\n /** Executes a recurring job */\n private runCronJob(job: ServerCronJon): void {\n (async (): Promise<void> => {\n reportInfo({ message: `Starting scheduled job \"${job.handler.name}\"` });\n try {\n await job.handler();\n reportInfo({\n message: `Job \"${job.handler.name}\" finished, starting again in ${job.interval} seconds`\n });\n await setTimeoutPromise(job.interval * 1000, undefined, {\n signal: this.abortController.signal\n });\n this.runCronJob(job);\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n reportDebug({\n namespace,\n message: `Scheduled job \"${job.handler?.name}\" has been aborted`\n });\n } else {\n throw error;\n }\n }\n })().catch((error) => {\n reportError(error);\n });\n }\n\n /** Run a shutdown/init callback */\n private runCallback(callback: ServerCallback): unknown {\n return typeof callback === 'function'\n ? callback()\n : callback.function.apply(null, callback.parameters ?? []);\n }\n\n /**\n * Validate the Server constructor configuration\n */\n private validate(config: ServerOptions): void {\n if (\n !config.endpoints ||\n config.endpoints.some((endpoint) => !(endpoint instanceof Endpoint))\n )\n throw new EngineError(\n 'Server endpoints should be declared and all be Endpoint instances'\n );\n\n if (\n config.checkEnvironment &&\n Object.values(config.checkEnvironment).some(\n (validator) => typeof validator !== 'function'\n )\n )\n throw new EngineError(\n 'Some of the environment checks are not valid functions'\n );\n\n if (\n config.initCallbacks &&\n (!(config.initCallbacks instanceof Array) ||\n config.initCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Init callbacks is not a list of functions');\n\n if (\n config.shutdownCallbacks &&\n (!(config.shutdownCallbacks instanceof Array) ||\n config.shutdownCallbacks.some(\n (callback) =>\n !(\n typeof callback === 'function' ||\n typeof callback?.function === 'function'\n )\n ))\n )\n throw new EngineError('Shutdown callbacks is not a list of functions');\n }\n}\n"],"mappings":";;;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A,MAAM,CAACO,SAAS,IACjBP,MAAM,CAACO,SAAS,CAACwH,IAAI,CAAExB,QAAQ,IAAK,EAAEA,QAAQ,YAAYyB,kBAAQ,CAAC,CAAC,EAEpE,MAAM,IAAIC,wBAAW,CACnB,mEACF,CAAC;MAEH,IACEjI,MAAM,CAACQ,gBAAgB,IACvB0H,MAAM,CAACC,MAAM,CAACnI,MAAM,CAACQ,gBAAgB,CAAC,CAACuH,IAAI,CACxCK,SAAS,IAAK,OAAOA,SAAS,KAAK,UACtC,CAAC,EAED,MAAM,IAAIH,wBAAW,CACnB,wDACF,CAAC;MAEH,IACEjI,MAAM,CAACW,aAAa,KACnB,EAAEX,MAAM,CAACW,aAAa,YAAY0H,KAAK,CAAC,IACvCrI,MAAM,CAACW,aAAa,CAACoH,IAAI,CACtBtE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEmE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,2CAA2C,CAAC;MAEpE,IACEjI,MAAM,CAACY,iBAAiB,KACvB,EAAEZ,MAAM,CAACY,iBAAiB,YAAYyH,KAAK,CAAC,IAC3CrI,MAAM,CAACY,iBAAiB,CAACmH,IAAI,CAC1BtE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEmE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,+CAA+C,CAAC;IAC1E;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Server.js","names":["_fs","_interopRequireDefault","require","_path","_promises","_express","_ws","_SocketClient","_Server2","_Endpoint","_EngineError","_LifecycleController","_PubSub","_utils","_jwt","_report","_tlsConfig","namespace","Server","exports","config","_classCallCheck2","default","app","httpServer","secondaryApp","secondaryHttpServer","endpoints","checkEnvironment","globalMiddleware","errorMiddleware","initCallbacks","shutdownCallbacks","syncCallbacks","cron","auth","wss","abortController","AbortController","validate","reportDebug","message","noFetch","process","env","RUN_MIGRATION","UNDO_MIGRATION","SQL_HOST","envAssert","isHost","SQL_USER","isString","SQL_PASSWORD","SQL_DB","NODE_ENV","PORT","isPort","SECONDARY_PORT","express","registerMiddleware","createHttpServer","secondaryMiddleware","defaultErrorMiddleware","forEach","middleware","use","disable","server","headersTimeout","keepAliveTimeout","webSocket","attachWebSocket","_createClass2","key","value","init","initKeySets","callback","runCallback","Promise","all","map","PubSub","job","runCronJob","resolve","listen","reportInfo","data","port","secondaryPort","nodeEnv","handleSignal","watchTlsCaFileChange","shutdown","listening","address","on","error","reportError","exit","close","clients","socket","socketKillTimeout","WEBSOCKET_CLOSE_TIMEOUT","parseInt","setTimeout","readyState","CLOSING","OPEN","terminate","LifecycleController","shutdownRunningInstances","abort","shutdownKeySets","shutdownSignals","signal","removeAllListeners","getApp","getSecondaryApp","defaultMiddleware","path","endpoint","register","options","WebSocketServer","request","SocketClient","client","catch","file","fs","watch","event","loadTlsConfig","setSecureContext","tlsConfig","handler","name","interval","setTimeoutPromise","undefined","Error","function","apply","parameters","some","Endpoint","EngineError","Object","values","validator","Array"],"sources":["../../../src/entities/Server/Server.ts"],"sourcesContent":["import fs from 'fs';\r\nimport http from 'http';\r\nimport https from 'https';\r\nimport { AddressInfo } from 'net';\r\nimport path from 'path';\r\nimport { setTimeout as setTimeoutPromise } from 'timers/promises';\r\nimport { ValidatorSpec } from 'envalid';\r\nimport express, { Application } from 'express';\r\nimport { Server as WebSocketServer } from 'ws';\r\nimport { SocketClient } from '../SocketClient';\r\nimport {\r\n defaultMiddleware,\r\n defaultErrorMiddleware,\r\n secondaryMiddleware,\r\n shutdownSignals\r\n} from './Server.const';\r\nimport {\r\n ServerOptions,\r\n ServerCronJon,\r\n ServerAuthConfig,\r\n ServerWebSocketConfig,\r\n ServerGlobalMiddleware,\r\n ServerErrorMiddleWare,\r\n ServerCallback\r\n} from './Server.types';\r\nimport { Endpoint } from 'entities/Endpoint';\r\nimport { EngineError } from 'entities/EngineError';\r\nimport { LifecycleController } from 'entities/LifecycleController';\r\nimport { PubSub } from 'entities/PubSub';\r\nimport { checkEnvironment, envAssert, createHttpServer } from 'utils';\r\nimport { initKeySets, shutdownKeySets } from 'utils/jwt';\r\nimport { reportInfo, reportError, reportDebug } from 'utils/report';\r\nimport { tlsConfig, loadTlsConfig, TlsConfig } from 'utils/tlsConfig';\r\n\r\nconst namespace = 'engine:Server';\r\n\r\n/** Main server class */\r\nexport class Server {\r\n /** The express application powering the main endpoints */\r\n private app: Application;\r\n /** The node HTTP(S) server, serving the main express application */\r\n private httpServer: http.Server | https.Server;\r\n /** The express application powering the support endpoints */\r\n private secondaryApp: Application;\r\n /** The node HTTP(S) server, serving the secondary express application */\r\n private secondaryHttpServer: http.Server | https.Server;\r\n /** List of endpoint instances that the server should handle */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n private endpoints: Array<Endpoint<any>>;\r\n /** Mapping of env variable name with functions that should run to check their validity */\r\n private checkEnvironment: Record<string, ValidatorSpec<unknown>>;\r\n /** Middleware that should run on every request before the endpoint specific logic */\r\n private globalMiddleware: Array<ServerGlobalMiddleware>;\r\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\r\n private errorMiddleware: Array<\r\n ServerGlobalMiddleware | ServerErrorMiddleWare\r\n >;\r\n /** Functions that should be called on server startup */\r\n private initCallbacks: Array<ServerCallback>;\r\n /** Functions that should be called on server shutdown */\r\n private shutdownCallbacks: Array<ServerCallback>;\r\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\r\n private syncCallbacks: boolean;\r\n /** Config to set regularly running jobs on the server */\r\n private cron?: Array<ServerCronJon>;\r\n /** Global auth related configuration */\r\n private auth: ServerAuthConfig;\r\n /** WebSocket server instance, if configured */\r\n private wss?: WebSocketServer;\r\n /** Abort controller that handles signals for the server */\r\n private abortController = new AbortController();\r\n\r\n /** Create a server */\r\n public constructor(config: ServerOptions) {\r\n this.validate(config);\r\n\r\n reportDebug({\r\n namespace,\r\n message: `Creating server`\r\n });\r\n\r\n this.endpoints = config.endpoints;\r\n this.globalMiddleware = config.globalMiddleware ?? [];\r\n this.errorMiddleware = config.errorMiddleware ?? [];\r\n this.initCallbacks = config.initCallbacks ?? [];\r\n this.shutdownCallbacks = config.shutdownCallbacks ?? [];\r\n this.syncCallbacks = config.syncCallbacks ?? false;\r\n this.cron = config.cron;\r\n this.auth = { noFetch: false, ...config.auth };\r\n\r\n // The minimal environment check is different between the migration modes of execution and the regular server execution mode\r\n // When running in migration mode, we only check that we have SQL related environment variables\r\n this.checkEnvironment =\r\n process.env.RUN_MIGRATION === 'true' ||\r\n process.env.UNDO_MIGRATION === 'true'\r\n ? {\r\n SQL_HOST: envAssert.isHost(),\r\n SQL_USER: envAssert.isString(),\r\n SQL_PASSWORD: envAssert.isString(),\r\n SQL_DB: envAssert.isString()\r\n }\r\n : {\r\n NODE_ENV: envAssert.isString(),\r\n PORT: envAssert.isPort(),\r\n SECONDARY_PORT: envAssert.isPort(),\r\n ...config.checkEnvironment\r\n };\r\n\r\n checkEnvironment(this.checkEnvironment);\r\n\r\n // Create the primary express core that serves the business logic\r\n this.app = express();\r\n this.registerMiddleware(this.app);\r\n this.httpServer = createHttpServer(this.app);\r\n\r\n // Create a secondary express core that servers metrics and analytics\r\n // This will be served on a different port, allowing to specify different firewall rules for these routes\r\n this.secondaryApp = express();\r\n [...secondaryMiddleware, ...defaultErrorMiddleware].forEach(\r\n (middleware) => {\r\n if (middleware) this.secondaryApp.use(middleware);\r\n }\r\n );\r\n this.secondaryHttpServer = createHttpServer(this.secondaryApp);\r\n\r\n // Remove the express headers\r\n this.app.disable('x-powered-by');\r\n this.secondaryApp.disable('x-powered-by');\r\n\r\n // We remove all node timeout on connections and requests\r\n // This responsibility is delegated to the front-facing load balancer\r\n [this.httpServer, this.secondaryHttpServer].forEach((server) => {\r\n server.headersTimeout = 0;\r\n server.keepAliveTimeout = 0;\r\n });\r\n\r\n if (config.webSocket) {\r\n this.attachWebSocket(config.webSocket);\r\n }\r\n }\r\n\r\n /** Start the server */\r\n public async init(): Promise<void> {\r\n reportDebug({ namespace, message: `Starting Server` });\r\n // Fetch the keys for JWT authentication\r\n // Ignore in test environment as we do symmetrical token signing\r\n if (process.env.NODE_ENV !== 'test' && !this.auth.noFetch)\r\n await initKeySets();\r\n // Run all the init callbacks\r\n // We can either run them all 1/1 synchronously or run them all in parallel (default)\r\n // Callback can either be direct function or an object with function and parameters attributes\r\n\r\n if (this.syncCallbacks) {\r\n for (const callback of this.initCallbacks) {\r\n await this.runCallback(callback);\r\n }\r\n } else {\r\n await Promise.all(\r\n this.initCallbacks.map((callback) => this.runCallback(callback))\r\n );\r\n }\r\n\r\n // Initialize the Pub/Sub module\r\n await PubSub.init();\r\n // Run all the cronjob\r\n if (this.cron) {\r\n this.cron.forEach((job) => {\r\n this.runCronJob(job);\r\n });\r\n }\r\n\r\n // Start listening to requests\r\n await Promise.all([\r\n new Promise<void>((resolve) =>\r\n this.httpServer.listen(process.env.PORT, () => {\r\n resolve();\r\n })\r\n ),\r\n new Promise<void>((resolve) =>\r\n this.secondaryHttpServer.listen(process.env.SECONDARY_PORT, () => {\r\n resolve();\r\n })\r\n )\r\n ]);\r\n reportInfo({\r\n message: 'SERVER_RUNNING',\r\n data: {\r\n port: process.env.PORT,\r\n secondaryPort: process.env.SECONDARY_PORT,\r\n nodeEnv: process.env.NODE_ENV\r\n }\r\n });\r\n\r\n this.handleSignal();\r\n\r\n // Watch TSL config files changing\r\n this.watchTlsCaFileChange();\r\n }\r\n\r\n /** Graceful shutdown */\r\n public async shutdown(): Promise<void> {\r\n reportDebug({ namespace, message: `Shutting down Server` });\r\n\r\n // Stop listening to HTTP requests\r\n await Promise.all(\r\n [this.httpServer, this.secondaryHttpServer].map((server) => {\r\n // Ignore if the server was already stopped\r\n // We have observed cases where SIGTERM was thrown multiple times\r\n if (!server.listening) return;\r\n const { port } = server.address() as AddressInfo;\r\n server.on('close', (error: unknown) => {\r\n if (error) {\r\n reportError(error);\r\n process.exit(1);\r\n } else {\r\n reportInfo({\r\n message: `Stopped listening to requests on port ${port}`\r\n });\r\n }\r\n });\r\n server.close();\r\n })\r\n );\r\n\r\n // Close all socket connections\r\n if (this.wss) {\r\n // First ask then to close gracefully\r\n this.wss.clients.forEach((socket) => {\r\n socket.close();\r\n });\r\n // Hard terminate all connections still open after a defined time\r\n const socketKillTimeout = process.env.WEBSOCKET_CLOSE_TIMEOUT\r\n ? parseInt(process.env.WEBSOCKET_CLOSE_TIMEOUT)\r\n : 5000;\r\n await new Promise<void>((resolve) => {\r\n setTimeout(() => {\r\n (this.wss as WebSocketServer).clients.forEach((socket) => {\r\n if (\r\n socket.readyState === socket.CLOSING ||\r\n socket.readyState === socket.OPEN\r\n ) {\r\n socket.terminate();\r\n }\r\n });\r\n resolve();\r\n }, socketKillTimeout);\r\n });\r\n }\r\n\r\n // Run all the shutdown callback\r\n if (this.syncCallbacks) {\r\n for (const callback of this.shutdownCallbacks) {\r\n await this.runCallback(callback);\r\n }\r\n } else {\r\n await Promise.all(\r\n this.shutdownCallbacks.map((callback) => this.runCallback(callback))\r\n );\r\n }\r\n\r\n // Shutdown all the running entities\r\n await LifecycleController.shutdownRunningInstances();\r\n\r\n // Abort all the cronjob\r\n if (this.abortController) this.abortController.abort();\r\n\r\n // Stop the keyset timers\r\n shutdownKeySets();\r\n\r\n shutdownSignals.forEach((signal) => process.removeAllListeners(signal));\r\n }\r\n\r\n /** Get the express app instance of the server */\r\n public getApp(): Application {\r\n return this.app;\r\n }\r\n\r\n /** Get the express app instance of the server */\r\n public getSecondaryApp(): Application {\r\n return this.secondaryApp;\r\n }\r\n\r\n /** Registers all the middleware with the express app */\r\n private registerMiddleware(app: Application): void {\r\n // Global middleware can specify a path to which they apply\r\n [...defaultMiddleware, ...this.globalMiddleware].forEach((middleware) => {\r\n if (typeof middleware === 'function') {\r\n app.use(middleware);\r\n } else {\r\n app.use(middleware.path, middleware.middleware);\r\n }\r\n });\r\n // Call the register method of each endpoint\r\n this.endpoints.forEach((endpoint) => {\r\n endpoint.register(app);\r\n });\r\n // Add error middleware\r\n [...this.errorMiddleware, ...defaultErrorMiddleware].forEach(\r\n (middleware) => {\r\n if (typeof middleware === 'function') {\r\n app.use(middleware);\r\n } else {\r\n app.use(middleware.path, middleware.middleware);\r\n }\r\n }\r\n );\r\n }\r\n\r\n /** Add a handler for WebSocket connections */\r\n private attachWebSocket(options: ServerWebSocketConfig): void {\r\n this.wss = new WebSocketServer({\r\n ...options.server,\r\n server: this.httpServer\r\n })\r\n .on('connection', (webSocket, request) => {\r\n new SocketClient(webSocket, request, options.client);\r\n })\r\n .on('error', (error) => {\r\n reportError(error);\r\n });\r\n }\r\n\r\n /** Call shutdown if signal gets sent to the process */\r\n private handleSignal(): void {\r\n shutdownSignals.forEach((signal) =>\r\n process.on(signal, () => {\r\n (async (): Promise<void> => {\r\n reportInfo(`Received shutdown signal [${signal}]`);\r\n await this.shutdown();\r\n })().catch((error) => {\r\n reportError(error);\r\n });\r\n })\r\n );\r\n }\r\n\r\n /** Watch the TLS certificate change event */\r\n private watchTlsCaFileChange(): void {\r\n [\r\n 'TLS_REQUEST_KEY',\r\n 'TLS_REQUEST_KEY_PASSPHRASE',\r\n 'TLS_REQUEST_CERT',\r\n 'TLS_REQUEST_CA',\r\n 'TLS_SERVER_KEY',\r\n 'TLS_SERVER_KEY_PASSPHRASE',\r\n 'TLS_SERVER_CERT',\r\n 'TLS_CA'\r\n ].forEach((key) => {\r\n const file = process.env[key];\r\n if (file)\r\n fs.watch(path.resolve(file), (event) => {\r\n if (event !== 'change') return;\r\n reportInfo(`Reloading TLS config [${file} changed]`);\r\n loadTlsConfig();\r\n (this.httpServer as https.Server).setSecureContext(\r\n tlsConfig as TlsConfig\r\n );\r\n });\r\n });\r\n }\r\n\r\n /** Executes a recurring job */\r\n private runCronJob(job: ServerCronJon): void {\r\n (async (): Promise<void> => {\r\n reportInfo({ message: `Starting scheduled job \"${job.handler.name}\"` });\r\n try {\r\n await job.handler();\r\n reportInfo({\r\n message: `Job \"${job.handler.name}\" finished, starting again in ${job.interval} seconds`\r\n });\r\n await setTimeoutPromise(job.interval * 1000, undefined, {\r\n signal: this.abortController.signal\r\n });\r\n this.runCronJob(job);\r\n } catch (error) {\r\n if (error instanceof Error && error.name === 'AbortError') {\r\n reportDebug({\r\n namespace,\r\n message: `Scheduled job \"${job.handler?.name}\" has been aborted`\r\n });\r\n } else {\r\n throw error;\r\n }\r\n }\r\n })().catch((error) => {\r\n reportError(error);\r\n });\r\n }\r\n\r\n /** Run a shutdown/init callback */\r\n private runCallback(callback: ServerCallback): unknown {\r\n return typeof callback === 'function'\r\n ? callback()\r\n : callback.function.apply(null, callback.parameters ?? []);\r\n }\r\n\r\n /**\r\n * Validate the Server constructor configuration\r\n */\r\n private validate(config: ServerOptions): void {\r\n if (\r\n !config.endpoints ||\r\n config.endpoints.some((endpoint) => !(endpoint instanceof Endpoint))\r\n )\r\n throw new EngineError(\r\n 'Server endpoints should be declared and all be Endpoint instances'\r\n );\r\n\r\n if (\r\n config.checkEnvironment &&\r\n Object.values(config.checkEnvironment).some(\r\n (validator) => typeof validator !== 'function'\r\n )\r\n )\r\n throw new EngineError(\r\n 'Some of the environment checks are not valid functions'\r\n );\r\n\r\n if (\r\n config.initCallbacks &&\r\n (!(config.initCallbacks instanceof Array) ||\r\n config.initCallbacks.some(\r\n (callback) =>\r\n !(\r\n typeof callback === 'function' ||\r\n typeof callback?.function === 'function'\r\n )\r\n ))\r\n )\r\n throw new EngineError('Init callbacks is not a list of functions');\r\n\r\n if (\r\n config.shutdownCallbacks &&\r\n (!(config.shutdownCallbacks instanceof Array) ||\r\n config.shutdownCallbacks.some(\r\n (callback) =>\r\n !(\r\n typeof callback === 'function' ||\r\n typeof callback?.function === 'function'\r\n )\r\n ))\r\n )\r\n throw new EngineError('Shutdown callbacks is not a list of functions');\r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qB,EAAQ;MAC5C,IACE,CAACA,MAAM,CAACO,SAAS,IACjBP,MAAM,CAACO,SAAS,CAACwH,IAAI,CAAExB,QAAQ,IAAK,EAAEA,QAAQ,YAAYyB,kBAAQ,CAAC,CAAC,EAEpE,MAAM,IAAIC,wBAAW,CACnB,mEACF,CAAC;MAEH,IACEjI,MAAM,CAACQ,gBAAgB,IACvB0H,MAAM,CAACC,MAAM,CAACnI,MAAM,CAACQ,gBAAgB,CAAC,CAACuH,IAAI,CACxCK,SAAS,IAAK,OAAOA,SAAS,KAAK,UACtC,CAAC,EAED,MAAM,IAAIH,wBAAW,CACnB,wDACF,CAAC;MAEH,IACEjI,MAAM,CAACW,aAAa,KACnB,EAAEX,MAAM,CAACW,aAAa,YAAY0H,KAAK,CAAC,IACvCrI,MAAM,CAACW,aAAa,CAACoH,IAAI,CACtBtE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEmE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,2CAA2C,CAAC;MAEpE,IACEjI,MAAM,CAACY,iBAAiB,KACvB,EAAEZ,MAAM,CAACY,iBAAiB,YAAYyH,KAAK,CAAC,IAC3CrI,MAAM,CAACY,iBAAiB,CAACmH,IAAI,CAC1BtE,QAAQ,IACP,EACE,OAAOA,QAAQ,KAAK,UAAU,IAC9B,OAAOA,QAAQ,EAAEmE,QAAQ,KAAK,UAAU,CAE9C,CAAC,CAAC,EAEJ,MAAM,IAAIK,wBAAW,CAAC,+CAA+C,CAAC;IAC1E;EAAC;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.types.js","names":[],"sources":["../../../src/entities/Server/Server.types.ts"],"sourcesContent":["import { ValidatorSpec } from 'envalid';\nimport { ErrorRequestHandler, RequestHandler } from 'express';\nimport { ServerOptions as WebSocketServerOptions } from 'ws';\nimport { Endpoint } from 'entities/Endpoint';\nimport { SocketClientOptions } from 'entities/SocketClient';\n\n/** Options to create a server */\nexport interface ServerOptions {\n /** List of endpoint instances that the server should handle */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n endpoints: Array<Endpoint<any>>;\n /** Mapping of env variable name with functions that should run to check their validity */\n checkEnvironment?: Record<string, ValidatorSpec<unknown>>;\n /** Middleware that should run on every request before the endpoint specific logic */\n globalMiddleware?: Array<ServerGlobalMiddleware>;\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\n errorMiddleware?: Array<ServerGlobalMiddleware | ServerErrorMiddleWare>;\n /** Functions that should be called on server startup */\n initCallbacks?: Array<ServerCallback>;\n /** Functions that should be called on server shutdown */\n shutdownCallbacks?: Array<ServerCallback>;\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\n syncCallbacks?: boolean;\n /** Config to set regularly running jobs on the server */\n cron?: Array<ServerCronJon>;\n /** Global auth related configuration */\n auth?: ServerAuthConfig;\n /** Configuration to enable webSocket connections to the server */\n webSocket?: ServerWebSocketConfig;\n}\n\n/** Options for a CRON task on the server */\nexport interface ServerCronJon {\n /** Function that is called when the job needs to run */\n handler: () => unknown;\n /** Interval (in seconds) between each job execution. The interval starts after the previous execution finished */\n interval: number;\n /** When this is set, the job is only run on the instance that is that has been elected leader of the service */\n leaderOnly?: boolean;\n}\n\n/** Common server authentication related config */\nexport interface ServerAuthConfig {\n /** Do not fetch JWT authentication parameters, this should be used on servers that do not receive public requests and therefore do not need access to the authentication service */\n noFetch?: boolean;\n}\n\n/** Configuration for WebSocket on this server */\nexport interface ServerWebSocketConfig {\n /** Options to pass to create the webSocket server */\n server: WebSocketServerOptions;\n /** Options to pass when creating socket client instances */\n client: SocketClientOptions;\n}\n\n/** Middleware function definition with path */\nexport interface ServerObjectGlobalMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: RequestHandler;\n}\nexport type ServerGlobalMiddleware =\n | RequestHandler\n | ServerObjectGlobalMiddleware;\n\n/** Error middleware function definition with path */\nexport interface ServerObjectErrorMiddleware {\n /** Path on which the middleware is used */\n path: string;\n /** Middleware function */\n middleware: ErrorRequestHandler;\n}\nexport type ServerErrorMiddleWare =\n | ErrorRequestHandler\n | ServerObjectErrorMiddleware;\n\ntype ServerFunctionCallback = (...args: Array<unknown>) => unknown;\n\n/** Callback definition with parameters */\ninterface ServerObjectCallback {\n /** Callback function */\n function: ServerFunctionCallback;\n /** Parameters to pass to the callback function */\n parameters?: Parameters<ServerFunctionCallback>;\n}\n\nexport type ServerCallback = ServerFunctionCallback | ServerObjectCallback;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Server.types.js","names":[],"sources":["../../../src/entities/Server/Server.types.ts"],"sourcesContent":["import { ValidatorSpec } from 'envalid';\r\nimport { ErrorRequestHandler, RequestHandler } from 'express';\r\nimport { ServerOptions as WebSocketServerOptions } from 'ws';\r\nimport { Endpoint } from 'entities/Endpoint';\r\nimport { SocketClientOptions } from 'entities/SocketClient';\r\n\r\n/** Options to create a server */\r\nexport interface ServerOptions {\r\n /** List of endpoint instances that the server should handle */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n endpoints: Array<Endpoint<any>>;\r\n /** Mapping of env variable name with functions that should run to check their validity */\r\n checkEnvironment?: Record<string, ValidatorSpec<unknown>>;\r\n /** Middleware that should run on every request before the endpoint specific logic */\r\n globalMiddleware?: Array<ServerGlobalMiddleware>;\r\n /** Error middleware that should run on every request after the endpoint specific logic, but before the generic global middleware */\r\n errorMiddleware?: Array<ServerGlobalMiddleware | ServerErrorMiddleWare>;\r\n /** Functions that should be called on server startup */\r\n initCallbacks?: Array<ServerCallback>;\r\n /** Functions that should be called on server shutdown */\r\n shutdownCallbacks?: Array<ServerCallback>;\r\n /** When set to true, this indicates that init callbacks should run synchronously in the order they are declared. By default they all run in parallel */\r\n syncCallbacks?: boolean;\r\n /** Config to set regularly running jobs on the server */\r\n cron?: Array<ServerCronJon>;\r\n /** Global auth related configuration */\r\n auth?: ServerAuthConfig;\r\n /** Configuration to enable webSocket connections to the server */\r\n webSocket?: ServerWebSocketConfig;\r\n}\r\n\r\n/** Options for a CRON task on the server */\r\nexport interface ServerCronJon {\r\n /** Function that is called when the job needs to run */\r\n handler: () => unknown;\r\n /** Interval (in seconds) between each job execution. The interval starts after the previous execution finished */\r\n interval: number;\r\n /** When this is set, the job is only run on the instance that is that has been elected leader of the service */\r\n leaderOnly?: boolean;\r\n}\r\n\r\n/** Common server authentication related config */\r\nexport interface ServerAuthConfig {\r\n /** Do not fetch JWT authentication parameters, this should be used on servers that do not receive public requests and therefore do not need access to the authentication service */\r\n noFetch?: boolean;\r\n}\r\n\r\n/** Configuration for WebSocket on this server */\r\nexport interface ServerWebSocketConfig {\r\n /** Options to pass to create the webSocket server */\r\n server: WebSocketServerOptions;\r\n /** Options to pass when creating socket client instances */\r\n client: SocketClientOptions;\r\n}\r\n\r\n/** Middleware function definition with path */\r\nexport interface ServerObjectGlobalMiddleware {\r\n /** Path on which the middleware is used */\r\n path: string;\r\n /** Middleware function */\r\n middleware: RequestHandler;\r\n}\r\nexport type ServerGlobalMiddleware =\r\n | RequestHandler\r\n | ServerObjectGlobalMiddleware;\r\n\r\n/** Error middleware function definition with path */\r\nexport interface ServerObjectErrorMiddleware {\r\n /** Path on which the middleware is used */\r\n path: string;\r\n /** Middleware function */\r\n middleware: ErrorRequestHandler;\r\n}\r\nexport type ServerErrorMiddleWare =\r\n | ErrorRequestHandler\r\n | ServerObjectErrorMiddleware;\r\n\r\ntype ServerFunctionCallback = (...args: Array<unknown>) => unknown;\r\n\r\n/** Callback definition with parameters */\r\ninterface ServerObjectCallback {\r\n /** Callback function */\r\n function: ServerFunctionCallback;\r\n /** Parameters to pass to the callback function */\r\n parameters?: Parameters<ServerFunctionCallback>;\r\n}\r\n\r\nexport type ServerCallback = ServerFunctionCallback | ServerObjectCallback;\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Server","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Server2"],"sources":["../../../src/entities/Server/index.ts"],"sourcesContent":["export * from './Server';\nexport * from './Server.types';\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Server","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Server2"],"sources":["../../../src/entities/Server/index.ts"],"sourcesContent":["export * from './Server';\r\nexport * from './Server.types';\r\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -18,12 +18,12 @@ var _jwt = require("../../utils/jwt");
|
|
|
18
18
|
var _report = require("../../utils/report");
|
|
19
19
|
const namespace = 'SocketClient';
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Class where each instance represents a client connected through web-sockets
|
|
21
|
+
/**
|
|
22
|
+
* Class where each instance represents a client connected through web-sockets
|
|
23
23
|
*/
|
|
24
24
|
let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
25
|
-
/**
|
|
26
|
-
* Create a WS client
|
|
25
|
+
/**
|
|
26
|
+
* Create a WS client
|
|
27
27
|
*/
|
|
28
28
|
function SocketClient(webSocket, request, options) {
|
|
29
29
|
(0, _classCallCheck2.default)(this, SocketClient);
|
|
@@ -152,8 +152,8 @@ let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
|
152
152
|
return (0, _createClass2.default)(SocketClient, [{
|
|
153
153
|
key: "sendMessage",
|
|
154
154
|
value:
|
|
155
|
-
/**
|
|
156
|
-
* Send a message to the client
|
|
155
|
+
/**
|
|
156
|
+
* Send a message to the client
|
|
157
157
|
*/
|
|
158
158
|
function sendMessage(type, payload = {}, options = {}) {
|
|
159
159
|
(0, _report.reportDebug)({
|
|
@@ -233,9 +233,9 @@ let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
/**
|
|
237
|
-
* Process an authentication request
|
|
238
|
-
* @param {String} message - Authentication message
|
|
236
|
+
/**
|
|
237
|
+
* Process an authentication request
|
|
238
|
+
* @param {String} message - Authentication message
|
|
239
239
|
*/
|
|
240
240
|
}, {
|
|
241
241
|
key: "authenticate",
|
|
@@ -282,8 +282,8 @@ let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
|
282
282
|
if (this.authExpireTimer) clearTimeout(this.authExpireTimer);
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
/**
|
|
286
|
-
* Fetch the user's data and attach it to the connection for new connections. For existing connections, it checks that the authentication is done on the same user.
|
|
285
|
+
/**
|
|
286
|
+
* Fetch the user's data and attach it to the connection for new connections. For existing connections, it checks that the authentication is done on the same user.
|
|
287
287
|
*/
|
|
288
288
|
}, {
|
|
289
289
|
key: "setUserData",
|
|
@@ -322,8 +322,8 @@ let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
/**
|
|
326
|
-
* Properly return errors to clients
|
|
325
|
+
/**
|
|
326
|
+
* Properly return errors to clients
|
|
327
327
|
*/
|
|
328
328
|
}, {
|
|
329
329
|
key: "handleError",
|
|
@@ -352,8 +352,8 @@ let SocketClient = exports.SocketClient = /*#__PURE__*/function () {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
/**
|
|
356
|
-
* Process a socket close event
|
|
355
|
+
/**
|
|
356
|
+
* Process a socket close event
|
|
357
357
|
*/
|
|
358
358
|
}, {
|
|
359
359
|
key: "handleClose",
|