node-server-engine 1.4.9 → 1.5.1
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/.commitlintrc.js +27 -0
- package/.releaserc.js +56 -0
- package/README.md +154 -2
- package/dist/const/tokenIssuer.js +1 -0
- package/dist/const/tokenIssuer.js.map +1 -1
- package/dist/db/models/SequelizeMeta.js +3 -1
- package/dist/db/models/SequelizeMeta.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.js +1 -2
- package/dist/entities/ElasticSearch/ElasticSearch.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.js +4 -1
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/entities/Server/Server.js +8 -11
- package/dist/entities/Server/Server.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.d.ts +4 -1
- package/dist/entities/SocketClient/SocketClient.js +5 -1
- package/dist/entities/SocketClient/SocketClient.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/checkPermission/checkPermission.d.ts +1 -1
- package/dist/middleware/checkPermission/checkPermission.js +4 -2
- package/dist/middleware/checkPermission/checkPermission.js.map +1 -1
- package/dist/utils/createSortedObject/createSortedObject.d.ts +5 -1
- package/dist/utils/createSortedObject/createSortedObject.js +13 -4
- package/dist/utils/createSortedObject/createSortedObject.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.js +34 -15
- package/dist/utils/dbMigration/dbMigration.js.map +1 -1
- package/dist/utils/geminiFileUpload/geminiFileUpload.js +2 -1
- package/dist/utils/geminiFileUpload/geminiFileUpload.js.map +1 -1
- package/dist/utils/jwt/jwt.js +1 -1
- package/dist/utils/jwt/jwt.js.map +1 -1
- package/dist/utils/report/report.d.ts +9 -3
- package/dist/utils/report/report.js +29 -12
- package/dist/utils/report/report.js.map +1 -1
- package/dist/utils/secretManager/secretLoader.js +5 -1
- package/dist/utils/secretManager/secretLoader.js.map +1 -1
- package/dist/utils/semverCompare/semverCompare.d.ts +4 -4
- package/dist/utils/semverCompare/semverCompare.js +16 -18
- package/dist/utils/semverCompare/semverCompare.js.map +1 -1
- package/package.json +30 -19
- package/.env.example +0 -186
- package/.github/workflows/publish.yml +0 -41
- package/.prettierrc +0 -7
- package/Dockerfile +0 -31
- package/babel.config.json +0 -34
- package/eslint.config.mjs +0 -11
- package/src/const/DebeziumEvent.ts +0 -6
- package/src/const/LogSeverity.ts +0 -7
- package/src/const/index.ts +0 -5
- package/src/const/metrics.ts +0 -6
- package/src/const/mime.ts +0 -37
- package/src/const/tokenIssuer.ts +0 -7
- package/src/db/migrations/20241030121500-create-sequelize-meta-table.ts +0 -29
- package/src/db/models/SequelizeMeta.ts +0 -16
- package/src/db/models/index.ts +0 -2
- package/src/entities/ElasticSearch/ElasticSearch.ts +0 -103
- package/src/entities/ElasticSearch/ElasticSearch.types.ts +0 -7
- package/src/entities/ElasticSearch/index.ts +0 -2
- package/src/entities/Endpoint/Endpoint.test.ts +0 -248
- package/src/entities/Endpoint/Endpoint.ts +0 -221
- package/src/entities/Endpoint/Endpoint.types.ts +0 -181
- package/src/entities/Endpoint/index.ts +0 -2
- package/src/entities/EngineError/EngineError.ts +0 -28
- package/src/entities/EngineError/EngineError.types.ts +0 -15
- package/src/entities/EngineError/index.ts +0 -2
- package/src/entities/KeySet/KeySet.test.ts +0 -126
- package/src/entities/KeySet/KeySet.ts +0 -172
- package/src/entities/KeySet/KeySet.types.ts +0 -28
- package/src/entities/KeySet/index.ts +0 -2
- package/src/entities/LifecycleController/LifecycleController.test.ts +0 -48
- package/src/entities/LifecycleController/LifecycleController.ts +0 -24
- package/src/entities/LifecycleController/LifecycleController.types.ts +0 -5
- package/src/entities/LifecycleController/index.ts +0 -2
- package/src/entities/Localizator/Localizator.ts +0 -139
- package/src/entities/Localizator/Localizator.types.ts +0 -52
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.test.ts +0 -165
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.ts +0 -58
- package/src/entities/Localizator/guessNamingConvention/index.ts +0 -1
- package/src/entities/Localizator/index.ts +0 -2
- package/src/entities/MessageHandler/MessageHandler.test.ts +0 -130
- package/src/entities/MessageHandler/MessageHandler.ts +0 -72
- package/src/entities/MessageHandler/MessageHandler.types.ts +0 -15
- package/src/entities/MessageHandler/index.ts +0 -2
- package/src/entities/PubSub/PubSub.test.ts +0 -297
- package/src/entities/PubSub/PubSub.ts +0 -202
- package/src/entities/PubSub/PubSub.types.ts +0 -76
- package/src/entities/PubSub/handleMessage/handleMessage.test.ts +0 -102
- package/src/entities/PubSub/handleMessage/handleMessage.ts +0 -65
- package/src/entities/PubSub/handleMessage/index.ts +0 -1
- package/src/entities/PubSub/index.ts +0 -2
- package/src/entities/PushNotification/PushNotification.test.ts +0 -35
- package/src/entities/PushNotification/PushNotification.ts +0 -44
- package/src/entities/PushNotification/PushNotification.types.ts +0 -25
- package/src/entities/PushNotification/index.ts +0 -2
- package/src/entities/Redis/Redis.ts +0 -71
- package/src/entities/Redis/Redis.types.ts +0 -19
- package/src/entities/Redis/Redis.validate.ts +0 -17
- package/src/entities/Redis/index.ts +0 -2
- package/src/entities/Sequelize/Sequelize.config.ts +0 -59
- package/src/entities/Sequelize/Sequelize.test.ts +0 -21
- package/src/entities/Sequelize/Sequelize.ts +0 -75
- package/src/entities/Sequelize/Sequelize.types.ts +0 -10
- package/src/entities/Sequelize/Sequelize.validate.ts +0 -15
- package/src/entities/Sequelize/index.ts +0 -2
- package/src/entities/Server/Server.const.ts +0 -56
- package/src/entities/Server/Server.test.ts +0 -272
- package/src/entities/Server/Server.ts +0 -471
- package/src/entities/Server/Server.types.ts +0 -88
- package/src/entities/Server/index.ts +0 -2
- package/src/entities/SocketClient/SocketClient.test.ts +0 -392
- package/src/entities/SocketClient/SocketClient.ts +0 -401
- package/src/entities/SocketClient/SocketClient.types.ts +0 -62
- package/src/entities/SocketClient/index.ts +0 -2
- package/src/entities/SocketClient/parseMessage/index.ts +0 -1
- package/src/entities/SocketClient/parseMessage/parseMessage.test.ts +0 -20
- package/src/entities/SocketClient/parseMessage/parseMessage.ts +0 -26
- package/src/entities/Storage/Storage.test.ts +0 -58
- package/src/entities/Storage/Storage.ts +0 -219
- package/src/entities/Storage/Storage.types.ts +0 -57
- package/src/entities/Storage/index.ts +0 -2
- package/src/entities/ValidationError/ValidationError.ts +0 -34
- package/src/entities/ValidationError/index.ts +0 -1
- package/src/entities/WebError/WebError.test.ts +0 -18
- package/src/entities/WebError/WebError.ts +0 -23
- package/src/entities/WebError/WebError.types.ts +0 -9
- package/src/entities/WebError/index.ts +0 -2
- package/src/entities/index.ts +0 -16
- package/src/index.ts +0 -6
- package/src/metrics/debug.ts +0 -10
- package/src/metrics/index.ts +0 -2
- package/src/metrics/request.ts +0 -17
- package/src/middleware/authHmac/authHmac.test.ts +0 -86
- package/src/middleware/authHmac/authHmac.ts +0 -56
- package/src/middleware/authHmac/authHmac.types.ts +0 -7
- package/src/middleware/authHmac/index.ts +0 -2
- package/src/middleware/authJwt/authJwt.test.ts +0 -54
- package/src/middleware/authJwt/authJwt.ts +0 -55
- package/src/middleware/authJwt/authJwt.types.ts +0 -14
- package/src/middleware/authJwt/index.ts +0 -2
- package/src/middleware/authStatic/authStatic.test.ts +0 -36
- package/src/middleware/authStatic/authStatic.ts +0 -45
- package/src/middleware/authStatic/index.ts +0 -1
- package/src/middleware/authTls/authTls.test.ts +0 -138
- package/src/middleware/authTls/authTls.ts +0 -119
- package/src/middleware/authTls/authTls.types.ts +0 -13
- package/src/middleware/authTls/index.ts +0 -2
- package/src/middleware/checkPermission/checkPermission.ts +0 -33
- package/src/middleware/checkPermission/index.ts +0 -1
- package/src/middleware/error/error.test.ts +0 -60
- package/src/middleware/error/error.ts +0 -25
- package/src/middleware/error/index.ts +0 -1
- package/src/middleware/fileUploader/fileUploader.ts +0 -154
- package/src/middleware/fileUploader/fileUploader.types.ts +0 -35
- package/src/middleware/fileUploader/index.ts +0 -2
- package/src/middleware/fileUploader/isMultiPart/index.ts +0 -1
- package/src/middleware/fileUploader/isMultiPart/isMultipart.ts +0 -9
- package/src/middleware/fileUploader/validate/index.ts +0 -1
- package/src/middleware/fileUploader/validate/validate.ts +0 -27
- package/src/middleware/fourOhFour/fourOhFour.test.ts +0 -14
- package/src/middleware/fourOhFour/fourOhFour.ts +0 -13
- package/src/middleware/fourOhFour/index.ts +0 -1
- package/src/middleware/geminiFileUploader/geminiFileUploader.ts +0 -68
- package/src/middleware/geminiFileUploader/index.ts +0 -1
- package/src/middleware/healthCheck/healthCheck.test.ts +0 -12
- package/src/middleware/healthCheck/healthCheck.ts +0 -14
- package/src/middleware/healthCheck/index.ts +0 -1
- package/src/middleware/index.ts +0 -17
- package/src/middleware/metrics/index.ts +0 -1
- package/src/middleware/metrics/metrics.test.ts +0 -46
- package/src/middleware/metrics/metrics.ts +0 -24
- package/src/middleware/multiPartFileUploader/index.ts +0 -2
- package/src/middleware/multiPartFileUploader/multiPartFileUploader.ts +0 -249
- package/src/middleware/multiPartFileUploader/multiPartFileUploader.types.ts +0 -23
- package/src/middleware/multiPartFileUploader/validate/index.ts +0 -1
- package/src/middleware/multiPartFileUploader/validate/validate.ts +0 -27
- package/src/middleware/requestMetrics/index.ts +0 -1
- package/src/middleware/requestMetrics/requestMetrics.test.ts +0 -77
- package/src/middleware/requestMetrics/requestMetrics.ts +0 -20
- package/src/middleware/swaggerDocs/index.ts +0 -2
- package/src/middleware/swaggerDocs/swaggerDocs.ts +0 -114
- package/src/middleware/swaggerDocs/swaggerDocs.types.ts +0 -41
- package/src/middleware/userResolver/index.ts +0 -1
- package/src/middleware/userResolver/userResolver.ts +0 -53
- package/src/middleware/validate/index.ts +0 -1
- package/src/middleware/validate/validate.test.ts +0 -43
- package/src/middleware/validate/validate.ts +0 -25
- package/src/middleware/version/index.ts +0 -1
- package/src/middleware/version/version.test.ts +0 -23
- package/src/middleware/version/version.ts +0 -12
- package/src/utils/checkEnvironment/index.ts +0 -49
- package/src/utils/createHttpServer/createHttpServer.test.ts +0 -24
- package/src/utils/createHttpServer/createHttpServer.ts +0 -34
- package/src/utils/createHttpServer/createHttpServer.validate.ts +0 -17
- package/src/utils/createHttpServer/index.ts +0 -1
- package/src/utils/createSortedObject/createSortedObject.ts +0 -20
- package/src/utils/createSortedObject/createSortedObjet.test.ts +0 -47
- package/src/utils/createSortedObject/index.ts +0 -1
- package/src/utils/dbMigration/dbMigration.test.ts +0 -209
- package/src/utils/dbMigration/dbMigration.ts +0 -199
- package/src/utils/dbMigration/dbMigration.types.ts +0 -11
- package/src/utils/dbMigration/index.ts +0 -2
- package/src/utils/dbMigration/migrateMetadataTable/index.ts +0 -1
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.test.ts +0 -59
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts +0 -102
- package/src/utils/envAssert/envAssert.ts +0 -31
- package/src/utils/envAssert/index.ts +0 -1
- package/src/utils/envAssert/validators/hostList.ts +0 -17
- package/src/utils/envAssert/validators/index.ts +0 -5
- package/src/utils/envAssert/validators/ipList.ts +0 -13
- package/src/utils/envAssert/validators/path.ts +0 -13
- package/src/utils/envAssert/validators/string.ts +0 -9
- package/src/utils/envAssert/validators/stringList.ts +0 -13
- package/src/utils/filter/filter.ts +0 -17
- package/src/utils/filter/index.ts +0 -1
- package/src/utils/geminiFileUpload/geminiFileUpload.ts +0 -93
- package/src/utils/geminiFileUpload/index.ts +0 -1
- package/src/utils/hmac/checkEnv/checkEnv.test.ts +0 -18
- package/src/utils/hmac/checkEnv/checkEnv.ts +0 -9
- package/src/utils/hmac/checkEnv/index.ts +0 -1
- package/src/utils/hmac/createHmac/createHmac.ts +0 -33
- package/src/utils/hmac/createHmac/index.ts +0 -1
- package/src/utils/hmac/index.ts +0 -4
- package/src/utils/hmac/index.types.ts +0 -13
- package/src/utils/hmac/signPayload/index.ts +0 -1
- package/src/utils/hmac/signPayload/signPayload.ts +0 -16
- package/src/utils/hmac/verifySignature/index.ts +0 -1
- package/src/utils/hmac/verifySignature/verifySignature.ts +0 -24
- package/src/utils/index.ts +0 -29
- package/src/utils/jwt/index.ts +0 -2
- package/src/utils/jwt/jwt.test.ts +0 -28
- package/src/utils/jwt/jwt.ts +0 -182
- package/src/utils/jwt/jwt.types.ts +0 -21
- package/src/utils/report/index.ts +0 -3
- package/src/utils/report/output.ts +0 -45
- package/src/utils/report/output.types.ts +0 -70
- package/src/utils/report/report.test.ts +0 -133
- package/src/utils/report/report.ts +0 -133
- package/src/utils/report/report.types.ts +0 -13
- package/src/utils/request/index.ts +0 -1
- package/src/utils/request/request.test.ts +0 -26
- package/src/utils/request/request.ts +0 -48
- package/src/utils/secretManager/index.ts +0 -2
- package/src/utils/secretManager/secretLoader.ts +0 -62
- package/src/utils/secretManager/secretResolver.ts +0 -35
- package/src/utils/semverCompare/index.ts +0 -1
- package/src/utils/semverCompare/semverCompare.test.ts +0 -49
- package/src/utils/semverCompare/semverCompare.ts +0 -60
- package/src/utils/sendEmail/index.ts +0 -2
- package/src/utils/sendEmail/sendEmail.ts +0 -61
- package/src/utils/sendEmail/sendEmail.types.ts +0 -61
- package/src/utils/sendPush/index.ts +0 -2
- package/src/utils/sendPush/sendPush.ts +0 -20
- package/src/utils/sendPush/sendPush.types.ts +0 -25
- package/src/utils/tlsConfig/index.ts +0 -2
- package/src/utils/tlsConfig/tlsConfig.test.ts +0 -32
- package/src/utils/tlsConfig/tlsConfig.ts +0 -47
- package/src/utils/tlsConfig/tlsConfig.types.ts +0 -11
- package/src/utils/tlsConfig/tlsConfig.validate.ts +0 -25
- package/src/utils/tlsRequest/index.ts +0 -1
- package/src/utils/tlsRequest/tlsRequest.test.ts +0 -63
- package/src/utils/tlsRequest/tlsRequest.ts +0 -12
- package/src/utils/trimPathSlash/index.ts +0 -1
- package/src/utils/trimPathSlash/trimPathSlash.test.ts +0 -26
- package/src/utils/trimPathSlash/trimPathSlash.ts +0 -8
- package/test/env.ts +0 -53
- package/test/factory/index.ts +0 -8
- package/test/factory/sequelizeMeta.ts +0 -12
- package/test/hooks.ts +0 -35
- package/test/index.ts +0 -3
- package/test/stub/index.ts +0 -3
- package/test/stub/stubLocales.ts +0 -68
- package/test/stub/stubPubSub.ts +0 -7
- package/test/stub/stubStorage.ts +0 -77
- package/test/stub/stubStorage.types.ts +0 -11
- package/test/utils/app.ts +0 -31
- package/test/utils/index.ts +0 -1
- package/tsconfig.build.json +0 -5
- package/tsconfig.json +0 -32
|
@@ -72,31 +72,43 @@ function reportError(error, request) {
|
|
|
72
72
|
}
|
|
73
73
|
let NAMESPACE_SELECTORS = exports.NAMESPACE_SELECTORS = void 0;
|
|
74
74
|
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Generate the namespace selectors based on the DEBUG environment variable
|
|
77
|
+
*/
|
|
76
78
|
function initNamespaceSelector() {
|
|
77
|
-
if (process.env.DEBUG)
|
|
79
|
+
if (process.env.DEBUG) {
|
|
80
|
+
exports.NAMESPACE_SELECTORS = NAMESPACE_SELECTORS = process.env.DEBUG.split(',').map(namespace => new RegExp(`^${namespace.replace(/\*/g, '.*?')}$`));
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Reset the namespace selectors
|
|
86
|
+
*/
|
|
81
87
|
function resetNamespaceSelector() {
|
|
82
88
|
exports.NAMESPACE_SELECTORS = NAMESPACE_SELECTORS = undefined;
|
|
83
89
|
}
|
|
84
90
|
let debugNamespace;
|
|
85
91
|
|
|
86
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Log a message for debugging purposes, based on a namespace specified in an environment variable
|
|
94
|
+
* @param data - Debug log entry data
|
|
95
|
+
* @returns The full log entry if namespace matches, undefined otherwise
|
|
96
|
+
*/
|
|
87
97
|
function reportDebug(data) {
|
|
88
|
-
if (!NAMESPACE_SELECTORS)
|
|
98
|
+
if (!NAMESPACE_SELECTORS) {
|
|
99
|
+
initNamespaceSelector();
|
|
100
|
+
}
|
|
89
101
|
let {
|
|
90
102
|
namespace
|
|
91
103
|
} = data;
|
|
92
|
-
const isEngineReport = namespace
|
|
93
|
-
if (debugNamespace && !isEngineReport) {
|
|
94
|
-
namespace = debugNamespace
|
|
104
|
+
const isEngineReport = namespace?.startsWith('engine') ?? false;
|
|
105
|
+
if (debugNamespace && !isEngineReport && namespace) {
|
|
106
|
+
namespace = `${debugNamespace}:${namespace}`;
|
|
95
107
|
}
|
|
96
108
|
const match = namespace && NAMESPACE_SELECTORS && NAMESPACE_SELECTORS.some(selector => selector.test(namespace));
|
|
97
|
-
if (!match) return;
|
|
109
|
+
if (!match) return undefined;
|
|
98
110
|
|
|
99
|
-
// Generate a prefix with the
|
|
111
|
+
// Generate a prefix with the rightmost part of the namespace
|
|
100
112
|
const spaces = namespace.split(':');
|
|
101
113
|
const prefix = spaces[spaces.length - 1];
|
|
102
114
|
return (0, _output.output)({
|
|
@@ -106,12 +118,17 @@ function reportDebug(data) {
|
|
|
106
118
|
});
|
|
107
119
|
}
|
|
108
120
|
|
|
109
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Specify a global debugging namespace
|
|
123
|
+
* @param globalNamespace - The namespace to set globally
|
|
124
|
+
*/
|
|
110
125
|
reportDebug.setNameSpace = function (globalNamespace) {
|
|
111
126
|
debugNamespace = globalNamespace;
|
|
112
127
|
};
|
|
113
128
|
|
|
114
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* Remove any defined global namespace
|
|
131
|
+
*/
|
|
115
132
|
reportDebug.clearNamespace = function () {
|
|
116
133
|
debugNamespace = undefined;
|
|
117
134
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","names":["_output","require","_const","_EngineError","_WebError","reportInfo","data","output","severity","LogSeverity","INFO","message","reportError","error","request","logEntry","Error","stack_trace","stack","ERROR","CRITICAL","EngineError","errorType","constructor","name","WebError","statusCode","undefined","errorCode","context","user","id","hosts","join","httpRequest","url","originalUrl","method","referrer","header","userAgent","remoteIp","ip","responseStatusCode","NAMESPACE_SELECTORS","exports","initNamespaceSelector","process","env","DEBUG","split","map","namespace","RegExp","replace","resetNamespaceSelector","debugNamespace","reportDebug","isEngineReport","startsWith","match","some","selector","test","spaces","prefix","length","setNameSpace","globalNamespace","clearNamespace"],"sources":["../../../src/utils/report/report.ts"],"sourcesContent":["import { Request } from 'express';\nimport { output } from './output';\nimport { LogEntry, FullLogEntry } from './output.types';\nimport { DebugLogEntry, InfoLogEntry } from './report.types';\nimport { LogSeverity } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { WebError } from 'entities/WebError';\nimport {} from 'middleware/authHmac/authHmac.types';\nimport {} from 'middleware/authJwt/authJwt.types';\nimport {} from 'middleware/authTls/authTls.types';\n\n/** Default generic logger */\nexport function reportInfo(data: InfoLogEntry | string): FullLogEntry {\n return output({\n severity: LogSeverity.INFO,\n ...(typeof data === 'string' ? { message: data } : data)\n });\n}\n\n/** Error specific logger */\nexport function reportError(\n error: unknown | Error | EngineError | WebError,\n request?: Request\n): FullLogEntry {\n let logEntry: LogEntry =\n error instanceof Error\n ? {\n message: error.message,\n stack_trace: error.stack,\n severity: LogSeverity.ERROR\n }\n : {\n message: 'An unknown error occurred',\n data: error,\n severity: LogSeverity.CRITICAL\n };\n\n if (error instanceof EngineError) {\n logEntry = {\n ...logEntry,\n severity: error.severity,\n errorType: error.constructor.name,\n data: error.data,\n '@type':\n !(error instanceof WebError) || error.statusCode >= 500\n ? 'type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent'\n : undefined\n };\n }\n\n if (error instanceof WebError) {\n logEntry = {\n ...logEntry,\n errorCode: error.errorCode,\n statusCode: error.statusCode\n };\n }\n\n if (request) {\n logEntry = {\n ...logEntry,\n context: {\n user:\n request.user?.id ?? request.hosts?.join(','),\n httpRequest: {\n url: request.originalUrl,\n method: request.method,\n referrer: request.header('Referer'),\n userAgent: request.header('User-Agent'),\n remoteIp: request.ip,\n responseStatusCode:\n error instanceof WebError ? error.statusCode : undefined\n }\n }\n };\n }\n\n return output(logEntry);\n}\n\nexport let NAMESPACE_SELECTORS:
|
|
1
|
+
{"version":3,"file":"report.js","names":["_output","require","_const","_EngineError","_WebError","reportInfo","data","output","severity","LogSeverity","INFO","message","reportError","error","request","logEntry","Error","stack_trace","stack","ERROR","CRITICAL","EngineError","errorType","constructor","name","WebError","statusCode","undefined","errorCode","context","user","id","hosts","join","httpRequest","url","originalUrl","method","referrer","header","userAgent","remoteIp","ip","responseStatusCode","NAMESPACE_SELECTORS","exports","initNamespaceSelector","process","env","DEBUG","split","map","namespace","RegExp","replace","resetNamespaceSelector","debugNamespace","reportDebug","isEngineReport","startsWith","match","some","selector","test","spaces","prefix","length","setNameSpace","globalNamespace","clearNamespace"],"sources":["../../../src/utils/report/report.ts"],"sourcesContent":["import { Request } from 'express';\nimport { output } from './output';\nimport { LogEntry, FullLogEntry } from './output.types';\nimport { DebugLogEntry, InfoLogEntry } from './report.types';\nimport { LogSeverity } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { WebError } from 'entities/WebError';\nimport {} from 'middleware/authHmac/authHmac.types';\nimport {} from 'middleware/authJwt/authJwt.types';\nimport {} from 'middleware/authTls/authTls.types';\n\n/** Default generic logger */\nexport function reportInfo(data: InfoLogEntry | string): FullLogEntry {\n return output({\n severity: LogSeverity.INFO,\n ...(typeof data === 'string' ? { message: data } : data)\n });\n}\n\n/** Error specific logger */\nexport function reportError(\n error: unknown | Error | EngineError | WebError,\n request?: Request\n): FullLogEntry {\n let logEntry: LogEntry =\n error instanceof Error\n ? {\n message: error.message,\n stack_trace: error.stack,\n severity: LogSeverity.ERROR\n }\n : {\n message: 'An unknown error occurred',\n data: error,\n severity: LogSeverity.CRITICAL\n };\n\n if (error instanceof EngineError) {\n logEntry = {\n ...logEntry,\n severity: error.severity,\n errorType: error.constructor.name,\n data: error.data,\n '@type':\n !(error instanceof WebError) || error.statusCode >= 500\n ? 'type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent'\n : undefined\n };\n }\n\n if (error instanceof WebError) {\n logEntry = {\n ...logEntry,\n errorCode: error.errorCode,\n statusCode: error.statusCode\n };\n }\n\n if (request) {\n logEntry = {\n ...logEntry,\n context: {\n user:\n request.user?.id ?? request.hosts?.join(','),\n httpRequest: {\n url: request.originalUrl,\n method: request.method,\n referrer: request.header('Referer'),\n userAgent: request.header('User-Agent'),\n remoteIp: request.ip,\n responseStatusCode:\n error instanceof WebError ? error.statusCode : undefined\n }\n }\n };\n }\n\n return output(logEntry);\n}\n\nexport let NAMESPACE_SELECTORS: Array<RegExp> | undefined;\n\n/**\n * Generate the namespace selectors based on the DEBUG environment variable\n */\nfunction initNamespaceSelector(): void {\n if (process.env.DEBUG) {\n NAMESPACE_SELECTORS = process.env.DEBUG.split(',').map(\n (namespace) => new RegExp(`^${namespace.replace(/\\*/g, '.*?')}$`)\n );\n }\n}\n\n/**\n * Reset the namespace selectors\n */\nexport function resetNamespaceSelector(): void {\n NAMESPACE_SELECTORS = undefined;\n}\n\nlet debugNamespace: string | undefined;\n\n/**\n * Log a message for debugging purposes, based on a namespace specified in an environment variable\n * @param data - Debug log entry data\n * @returns The full log entry if namespace matches, undefined otherwise\n */\nexport function reportDebug(data: DebugLogEntry): FullLogEntry | undefined {\n if (!NAMESPACE_SELECTORS) {\n initNamespaceSelector();\n }\n \n let { namespace } = data;\n const isEngineReport = namespace?.startsWith('engine') ?? false;\n\n if (debugNamespace && !isEngineReport && namespace) {\n namespace = `${debugNamespace}:${namespace}`;\n }\n\n const match =\n namespace &&\n NAMESPACE_SELECTORS &&\n NAMESPACE_SELECTORS.some((selector) => selector.test(namespace));\n \n if (!match) return undefined;\n\n // Generate a prefix with the rightmost part of the namespace\n const spaces = namespace.split(':');\n const prefix = spaces[spaces.length - 1];\n\n return output({\n severity: LogSeverity.DEBUG,\n ...data,\n message: `[${prefix}] ${data.message}`\n });\n}\n\n/**\n * Specify a global debugging namespace\n * @param globalNamespace - The namespace to set globally\n */\nreportDebug.setNameSpace = function (globalNamespace: string): void {\n debugNamespace = globalNamespace;\n};\n\n/**\n * Remove any defined global namespace\n */\nreportDebug.clearNamespace = function (): void {\n debugNamespace = undefined;\n};\n"],"mappings":";;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AAEA;AACO,SAASI,UAAUA,CAACC,IAA2B,EAAgB;EACpE,OAAO,IAAAC,cAAM,EAAC;IACZC,QAAQ,EAAEC,kBAAW,CAACC,IAAI;IAC1B,IAAI,OAAOJ,IAAI,KAAK,QAAQ,GAAG;MAAEK,OAAO,EAAEL;IAAK,CAAC,GAAGA,IAAI;EACzD,CAAC,CAAC;AACJ;;AAEA;AACO,SAASM,WAAWA,CACzBC,KAA+C,EAC/CC,OAAiB,EACH;EACd,IAAIC,QAAkB,GACpBF,KAAK,YAAYG,KAAK,GAClB;IACEL,OAAO,EAAEE,KAAK,CAACF,OAAO;IACtBM,WAAW,EAAEJ,KAAK,CAACK,KAAK;IACxBV,QAAQ,EAAEC,kBAAW,CAACU;EACxB,CAAC,GACD;IACER,OAAO,EAAE,2BAA2B;IACpCL,IAAI,EAAEO,KAAK;IACXL,QAAQ,EAAEC,kBAAW,CAACW;EACxB,CAAC;EAEP,IAAIP,KAAK,YAAYQ,wBAAW,EAAE;IAChCN,QAAQ,GAAG;MACT,GAAGA,QAAQ;MACXP,QAAQ,EAAEK,KAAK,CAACL,QAAQ;MACxBc,SAAS,EAAET,KAAK,CAACU,WAAW,CAACC,IAAI;MACjClB,IAAI,EAAEO,KAAK,CAACP,IAAI;MAChB,OAAO,EACL,EAAEO,KAAK,YAAYY,kBAAQ,CAAC,IAAIZ,KAAK,CAACa,UAAU,IAAI,GAAG,GACnD,oFAAoF,GACpFC;IACR,CAAC;EACH;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Module", {
|
|
|
6
6
|
exports.secretCache = exports.initializeSecrets = void 0;
|
|
7
7
|
var _secretManager = require("@google-cloud/secret-manager");
|
|
8
8
|
var _EngineError = require("../../entities/EngineError");
|
|
9
|
+
var _report = require("../report");
|
|
9
10
|
// Cache to store preloaded secrets
|
|
10
11
|
const secretCache = exports.secretCache = {};
|
|
11
12
|
let secretClient;
|
|
@@ -16,7 +17,10 @@ let secretClient;
|
|
|
16
17
|
*/
|
|
17
18
|
const initializeSecrets = async secretEnvVars => {
|
|
18
19
|
if (process.env.NODE_ENV !== 'production') {
|
|
19
|
-
|
|
20
|
+
(0, _report.reportDebug)({
|
|
21
|
+
namespace: 'engine:secretManager',
|
|
22
|
+
message: 'Development mode → using local files for secrets'
|
|
23
|
+
});
|
|
20
24
|
return; // No need to preload anything
|
|
21
25
|
}
|
|
22
26
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretLoader.js","names":["_secretManager","require","_EngineError","secretCache","exports","secretClient","initializeSecrets","secretEnvVars","process","env","NODE_ENV","
|
|
1
|
+
{"version":3,"file":"secretLoader.js","names":["_secretManager","require","_EngineError","_report","secretCache","exports","secretClient","initializeSecrets","secretEnvVars","process","env","NODE_ENV","reportDebug","namespace","message","SecretManagerServiceClient","secretNames","filter","name","length","EngineError","secretPath","version","accessSecretVersion","payload","data","toString","err"],"sources":["../../../src/utils/secretManager/secretLoader.ts"],"sourcesContent":["import { SecretManagerServiceClient } from '@google-cloud/secret-manager';\nimport { EngineError } from 'entities/EngineError';\nimport { reportDebug } from 'utils/report';\n\n// Cache to store preloaded secrets\nexport const secretCache: { [key: string]: string } = {};\nlet secretClient: SecretManagerServiceClient;\n\n/**\n * Initialize the Secret Manager client and preload secrets.\n * @param secretEnvVars List of env var names that contain secret paths\n */\nexport const initializeSecrets = async (\n secretEnvVars: string[]\n): Promise<void> => {\n if (process.env.NODE_ENV !== 'production') {\n reportDebug({\n namespace: 'engine:secretManager',\n message: 'Development mode → using local files for secrets'\n });\n return; // No need to preload anything\n }\n\n try {\n // Default creds (for GCP runtime)\n secretClient = new SecretManagerServiceClient();\n\n const secretNames = secretEnvVars.filter((name) => process.env[name]);\n if (secretNames.length === 0) {\n throw new EngineError({\n message: 'No secret names defined in environment variables'\n });\n }\n\n // Fetch all secrets from GCP Secret Manager\n for (const name of secretNames) {\n const secretPath = process.env[name];\n if (!secretPath) {\n throw new EngineError({\n message: `Secret path for ${name} is not defined`\n });\n }\n\n try {\n const [version] = await secretClient.accessSecretVersion({\n name: secretPath\n });\n const payload = version.payload?.data?.toString('utf-8');\n if (!payload) {\n throw new EngineError({\n message: `Secret ${name} not found or empty`\n });\n }\n secretCache[name] = payload;\n } catch (err) {\n throw new EngineError({\n message: `Error accessing secret ${name}: ${(err as Error).message}`\n });\n }\n }\n } catch (err) {\n throw new EngineError({\n message: `Failed to initialize secrets: ${(err as Error).message}`\n });\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACO,MAAMG,WAAsC,GAAAC,OAAA,CAAAD,WAAA,GAAG,CAAC,CAAC;AACxD,IAAIE,YAAwC;;AAE5C;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAG,MAC/BC,aAAuB,IACL;EAClB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAAC,mBAAW,EAAC;MACVC,SAAS,EAAE,sBAAsB;MACjCC,OAAO,EAAE;IACX,CAAC,CAAC;IACF,OAAO,CAAC;EACV;EAEA,IAAI;IACF;IACAR,YAAY,GAAG,IAAIS,yCAA0B,CAAC,CAAC;IAE/C,MAAMC,WAAW,GAAGR,aAAa,CAACS,MAAM,CAAEC,IAAI,IAAKT,OAAO,CAACC,GAAG,CAACQ,IAAI,CAAC,CAAC;IACrE,IAAIF,WAAW,CAACG,MAAM,KAAK,CAAC,EAAE;MAC5B,MAAM,IAAIC,wBAAW,CAAC;QACpBN,OAAO,EAAE;MACX,CAAC,CAAC;IACJ;;IAEA;IACA,KAAK,MAAMI,IAAI,IAAIF,WAAW,EAAE;MAC9B,MAAMK,UAAU,GAAGZ,OAAO,CAACC,GAAG,CAACQ,IAAI,CAAC;MACpC,IAAI,CAACG,UAAU,EAAE;QACf,MAAM,IAAID,wBAAW,CAAC;UACpBN,OAAO,EAAE,mBAAmBI,IAAI;QAClC,CAAC,CAAC;MACJ;MAEA,IAAI;QACF,MAAM,CAACI,OAAO,CAAC,GAAG,MAAMhB,YAAY,CAACiB,mBAAmB,CAAC;UACvDL,IAAI,EAAEG;QACR,CAAC,CAAC;QACF,MAAMG,OAAO,GAAGF,OAAO,CAACE,OAAO,EAAEC,IAAI,EAAEC,QAAQ,CAAC,OAAO,CAAC;QACxD,IAAI,CAACF,OAAO,EAAE;UACZ,MAAM,IAAIJ,wBAAW,CAAC;YACpBN,OAAO,EAAE,UAAUI,IAAI;UACzB,CAAC,CAAC;QACJ;QACAd,WAAW,CAACc,IAAI,CAAC,GAAGM,OAAO;MAC7B,CAAC,CAAC,OAAOG,GAAG,EAAE;QACZ,MAAM,IAAIP,wBAAW,CAAC;UACpBN,OAAO,EAAE,0BAA0BI,IAAI,KAAMS,GAAG,CAAWb,OAAO;QACpE,CAAC,CAAC;MACJ;IACF;EACF,CAAC,CAAC,OAAOa,GAAG,EAAE;IACZ,MAAM,IAAIP,wBAAW,CAAC;MACpBN,OAAO,EAAE,iCAAkCa,GAAG,CAAWb,OAAO;IAClE,CAAC,CAAC;EACJ;AACF,CAAC;AAACT,OAAA,CAAAE,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Comparison function for our SemVer strings, includes support
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
2
|
+
* Comparison function for our SemVer strings, includes support for pre-releases
|
|
3
|
+
* @param v1 - First version string to compare
|
|
4
|
+
* @param v2 - Second version string to compare
|
|
5
|
+
* @returns -1 if v1 < v2, 0 if v1 = v2, +1 if v1 > v2
|
|
6
6
|
*/
|
|
7
7
|
export declare function semverCompare(v1: string, v2: string): 1 | -1 | 0;
|
|
@@ -11,27 +11,25 @@ var _EngineError = require("../../entities/EngineError");
|
|
|
11
11
|
const SEMVER_REGEX = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:(alpha|beta|rc)(?:\.(0|[1-9]\d*))))?$/;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Comparison function for our SemVer strings, includes support
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @
|
|
14
|
+
* Comparison function for our SemVer strings, includes support for pre-releases
|
|
15
|
+
* @param v1 - First version string to compare
|
|
16
|
+
* @param v2 - Second version string to compare
|
|
17
|
+
* @returns -1 if v1 < v2, 0 if v1 = v2, +1 if v1 > v2
|
|
18
18
|
*/
|
|
19
19
|
function semverCompare(v1, v2) {
|
|
20
20
|
const [match1, match2] = [v1, v2].map(v => v.match(SEMVER_REGEX));
|
|
21
|
-
if (!match1 || !match2)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
[
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
// We parse to int the parts that can be
|
|
34
|
-
group.map(item => item && _validator.default.isInt(item) ? parseInt(item) : item));
|
|
21
|
+
if (!match1 || !match2) {
|
|
22
|
+
throw new _EngineError.EngineError({
|
|
23
|
+
message: 'Provided invalid SemVer string, cannot compare',
|
|
24
|
+
data: {
|
|
25
|
+
v1,
|
|
26
|
+
v2
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const [[, major1, minor1, patch1, preType1, preVersion1], [, major2, minor2, patch2, preType2, preVersion2]] = [match1, match2].map(group =>
|
|
31
|
+
// Parse numeric values
|
|
32
|
+
group.map(item => item && _validator.default.isInt(item) ? parseInt(item, 10) : item));
|
|
35
33
|
|
|
36
34
|
// Compare majors first
|
|
37
35
|
if (major1 < major2) return -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semverCompare.js","names":["_validator","_interopRequireDefault","require","_EngineError","SEMVER_REGEX","semverCompare","v1","v2","match1","match2","map","v","match","EngineError","message","data","
|
|
1
|
+
{"version":3,"file":"semverCompare.js","names":["_validator","_interopRequireDefault","require","_EngineError","SEMVER_REGEX","semverCompare","v1","v2","match1","match2","map","v","match","EngineError","message","data","major1","minor1","patch1","preType1","preVersion1","major2","minor2","patch2","preType2","preVersion2","group","item","validator","isInt","parseInt"],"sources":["../../../src/utils/semverCompare/semverCompare.ts"],"sourcesContent":["import validator from 'validator';\nimport { EngineError } from 'entities/EngineError';\n\n// Regex to validate our SemVer style and capture the different parts\nconst SEMVER_REGEX =\n /^v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(?:(alpha|beta|rc)(?:\\.(0|[1-9]\\d*))))?$/;\n\n/**\n * Comparison function for our SemVer strings, includes support for pre-releases\n * @param v1 - First version string to compare\n * @param v2 - Second version string to compare\n * @returns -1 if v1 < v2, 0 if v1 = v2, +1 if v1 > v2\n */\nexport function semverCompare(v1: string, v2: string): 1 | -1 | 0 {\n const [match1, match2] = [v1, v2].map((v) => v.match(SEMVER_REGEX));\n \n if (!match1 || !match2) {\n throw new EngineError({\n message: 'Provided invalid SemVer string, cannot compare',\n data: { v1, v2 }\n });\n }\n\n const [\n [, major1, minor1, patch1, preType1, preVersion1],\n [, major2, minor2, patch2, preType2, preVersion2]\n ] = [match1, match2].map((group) =>\n // Parse numeric values\n group.map((item) => (item && validator.isInt(item) ? parseInt(item, 10) : item))\n );\n\n // Compare majors first\n if (major1 < major2) return -1;\n if (major1 > major2) return 1;\n\n // Compare minors second\n if (minor1 < minor2) return -1;\n if (minor1 > minor2) return 1;\n\n // Compare patch third\n if (patch1 < patch2) return -1;\n if (patch1 > patch2) return 1;\n\n // Compare pre-release type\n // Release > pre-release\n if (!preType1 && !preType2) return 0;\n if (preType1 && !preType2) return -1;\n if (!preType1 && preType2) return 1;\n\n // RC > Beta > Alpha\n if (preType1 !== 'rc' && preType2 === 'rc') return -1;\n if (preType1 === 'rc' && preType2 !== 'rc') return 1;\n if (preType1 !== 'beta' && preType2 === 'beta') return -1;\n if (preType1 === 'beta' && preType2 !== 'beta') return 1;\n\n // Finally compare the pre-release versions\n if (preVersion1 < preVersion2) return -1;\n if (preVersion1 > preVersion2) return 1;\n\n return 0;\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA,MAAME,YAAY,GAChB,yFAAyF;;AAE3F;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,EAAU,EAAEC,EAAU,EAAc;EAChE,MAAM,CAACC,MAAM,EAAEC,MAAM,CAAC,GAAG,CAACH,EAAE,EAAEC,EAAE,CAAC,CAACG,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACC,KAAK,CAACR,YAAY,CAAC,CAAC;EAEnE,IAAI,CAACI,MAAM,IAAI,CAACC,MAAM,EAAE;IACtB,MAAM,IAAII,wBAAW,CAAC;MACpBC,OAAO,EAAE,gDAAgD;MACzDC,IAAI,EAAE;QAAET,EAAE;QAAEC;MAAG;IACjB,CAAC,CAAC;EACJ;EAEA,MAAM,CACJ,GAAGS,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,WAAW,CAAC,EACjD,GAAGC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,WAAW,CAAC,CAClD,GAAG,CAACjB,MAAM,EAAEC,MAAM,CAAC,CAACC,GAAG,CAAEgB,KAAK;EAC7B;EACAA,KAAK,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|
|
2
2
|
"name": "node-server-engine",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Framework used to develop backend services. This package ships with a lot of features to standardize the creation of services, letting you focus on the business logic.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rimraf dist && tsc -p tsconfig.build.json && shx mv dist/src/* dist && rimraf dist/src && tsc-alias -p tsconfig.build.json && npx babel src --out-dir dist --source-maps --extensions \".ts\" --ignore \"**/*.test.ts\" --copy-files --no-copy-ignored",
|
|
8
8
|
"format": "prettier --write .",
|
|
9
|
+
"format:check": "prettier --check .",
|
|
9
10
|
"lint": "eslint ./src",
|
|
10
11
|
"lint:fix": "eslint ./src --fix",
|
|
11
12
|
"prepublish": "npm run build",
|
|
@@ -15,18 +16,22 @@
|
|
|
15
16
|
"coverage": "nyc report --report-dir=./.test-coverage --reporter=html --reporter=text",
|
|
16
17
|
"coverage:ci": "nyc report --reporter=text-summary",
|
|
17
18
|
"test:ci": "npm run test -- --reporter spec",
|
|
18
|
-
"test:compose": "docker-compose up --abort-on-container-exit --build"
|
|
19
|
+
"test:compose": "docker-compose up --abort-on-container-exit --build",
|
|
20
|
+
"prepare": "husky"
|
|
19
21
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
"keywords": [
|
|
23
|
+
"node",
|
|
24
|
+
"express",
|
|
25
|
+
"server",
|
|
26
|
+
"backend",
|
|
27
|
+
"framework",
|
|
28
|
+
"rest-api",
|
|
29
|
+
"typescript",
|
|
30
|
+
"microservices",
|
|
31
|
+
"jwt",
|
|
32
|
+
"websocket",
|
|
33
|
+
"sequelize"
|
|
34
|
+
],
|
|
30
35
|
"author": "Ram",
|
|
31
36
|
"license": "ISC",
|
|
32
37
|
"repository": {
|
|
@@ -46,7 +51,7 @@
|
|
|
46
51
|
"@google/generative-ai": "^0.21.0",
|
|
47
52
|
"ajv": "^8.17.1",
|
|
48
53
|
"axios": "^1.7.9",
|
|
49
|
-
"backend-test-tools": "^1.
|
|
54
|
+
"backend-test-tools": "^1.1.2",
|
|
50
55
|
"body-parser": "^1.20.3",
|
|
51
56
|
"busboy": "^1.6.0",
|
|
52
57
|
"bytes": "^3.1.2",
|
|
@@ -71,18 +76,18 @@
|
|
|
71
76
|
"mime-types": "^2.1.35",
|
|
72
77
|
"morgan": "^1.10.0",
|
|
73
78
|
"ms": "^2.1.3",
|
|
74
|
-
"multer": "^
|
|
79
|
+
"multer": "^2.0.1",
|
|
75
80
|
"mysql2": "^3.11.5",
|
|
76
81
|
"nock": "^13.5.6",
|
|
77
|
-
"nodemailer": "^
|
|
82
|
+
"nodemailer": "^7.0.11",
|
|
78
83
|
"nodemon": "^3.1.9",
|
|
79
84
|
"pg": "^8.13.1",
|
|
80
85
|
"prom-client": "^15.1.3",
|
|
81
86
|
"request-ip": "^3.3.0",
|
|
82
87
|
"response-time": "^2.3.3",
|
|
83
88
|
"semver-compare": "^1.0.0",
|
|
84
|
-
"sequelize": "^6.37.
|
|
85
|
-
"sequelize-cli": "^6.6.
|
|
89
|
+
"sequelize": "^6.37.7",
|
|
90
|
+
"sequelize-cli": "^6.6.3",
|
|
86
91
|
"sequelize-typescript": "^2.1.6",
|
|
87
92
|
"sharp": "^0.33.5",
|
|
88
93
|
"swagger-ui-express": "^5.0.1",
|
|
@@ -103,8 +108,12 @@
|
|
|
103
108
|
"@babel/preset-env": "^7.26.0",
|
|
104
109
|
"@babel/preset-typescript": "^7.26.0",
|
|
105
110
|
"@babel/register": "^7.25.9",
|
|
111
|
+
"@commitlint/cli": "^19.8.1",
|
|
112
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
106
113
|
"@faker-js/faker": "^9.3.0",
|
|
107
114
|
"@google-cloud/precise-date": "^4.0.0",
|
|
115
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
116
|
+
"@semantic-release/git": "^10.0.1",
|
|
108
117
|
"@types/busboy": "^1.5.4",
|
|
109
118
|
"@types/bytes": "^3.1.5",
|
|
110
119
|
"@types/callsite": "^1.0.34",
|
|
@@ -127,7 +136,7 @@
|
|
|
127
136
|
"@types/node": "^22.10.2",
|
|
128
137
|
"@types/nodemailer": "^6.4.17",
|
|
129
138
|
"@types/response-time": "^2.3.8",
|
|
130
|
-
"@types/sequelize": "^
|
|
139
|
+
"@types/sequelize": "^6.12.0",
|
|
131
140
|
"@types/sinon-chai": "^4.0.0",
|
|
132
141
|
"@types/supertest": "^6.0.2",
|
|
133
142
|
"@types/swagger-ui-express": "^4.1.7",
|
|
@@ -141,6 +150,7 @@
|
|
|
141
150
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
142
151
|
"chai": "^4.5.0",
|
|
143
152
|
"chai-as-promised": "^7.1.2",
|
|
153
|
+
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
144
154
|
"cross-env": "^7.0.3",
|
|
145
155
|
"eslint": "^9.17.0",
|
|
146
156
|
"factory-waifu": "^1.0.1",
|
|
@@ -154,11 +164,12 @@
|
|
|
154
164
|
"nyc": "^17.1.0",
|
|
155
165
|
"prettier": "^3.4.2",
|
|
156
166
|
"rimraf": "^6.0.1",
|
|
167
|
+
"semantic-release": "^25.0.2",
|
|
157
168
|
"shx": "^0.3.4",
|
|
158
169
|
"sinon": "^19.0.2",
|
|
159
170
|
"sinon-chai": "^3.5.0",
|
|
160
171
|
"supertest": "^7.0.0",
|
|
161
|
-
"tmp": "^0.2.
|
|
172
|
+
"tmp": "^0.2.4",
|
|
162
173
|
"ts-node": "^10.9.2",
|
|
163
174
|
"tsc-alias": "^1.8.10",
|
|
164
175
|
"tsconfig-paths": "^4.2.0",
|
package/.env.example
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
## DEV ENV
|
|
2
|
-
NODE_ENV=
|
|
3
|
-
|
|
4
|
-
# Port on which the business logic endpoints are served
|
|
5
|
-
PORT=
|
|
6
|
-
|
|
7
|
-
# Port on which metrics and analytics data is served. It is used to allow different firewall rules for accessing the service
|
|
8
|
-
SECONDARY_PORT=
|
|
9
|
-
|
|
10
|
-
# Server host name
|
|
11
|
-
HOST_NAME=
|
|
12
|
-
|
|
13
|
-
# Timeout (in ms) for the websocket connections to close gracefully on server shutdown. After that, the connection is destroyed unilateraly
|
|
14
|
-
WEBSOCKET_CLOSE_TIMEOUT=
|
|
15
|
-
|
|
16
|
-
# Google Gemini AI key
|
|
17
|
-
GOOGLE_AI_KEY=
|
|
18
|
-
|
|
19
|
-
#######
|
|
20
|
-
# TLS #
|
|
21
|
-
#######
|
|
22
|
-
|
|
23
|
-
# Private key of the server
|
|
24
|
-
TLS_SERVER_KEY=
|
|
25
|
-
|
|
26
|
-
# Passphrase to decrypt the private key
|
|
27
|
-
TLS_SERVER_KEY_PASSPHRASE=
|
|
28
|
-
|
|
29
|
-
# Certificate of the server
|
|
30
|
-
TLS_SERVER_CERT=
|
|
31
|
-
|
|
32
|
-
# Certificate of the certifying authority
|
|
33
|
-
TLS_CA=
|
|
34
|
-
|
|
35
|
-
# Private key used to make a TLS request
|
|
36
|
-
# Defaults to the server key if not specified
|
|
37
|
-
TLS_REQUEST_KEY=
|
|
38
|
-
|
|
39
|
-
# Passphrase to decrypt the private key used to make a TLS request
|
|
40
|
-
# Defaults to the server passphrase if not specified
|
|
41
|
-
TLS_REQUEST_KEY_PASSPHRASE=
|
|
42
|
-
|
|
43
|
-
# Certificate used to make a TLS request
|
|
44
|
-
# Defaults to the server certificate if not specified
|
|
45
|
-
TLS_REQUEST_CERT=
|
|
46
|
-
|
|
47
|
-
# Certificate of the certifying authority used to make a TLS request
|
|
48
|
-
# Defaults to the server certificate of the certifying authority if not specified
|
|
49
|
-
TLS_REQUEST_CA=
|
|
50
|
-
|
|
51
|
-
# List of clients hosts allowed to make a request
|
|
52
|
-
# Comma separated string
|
|
53
|
-
ALLOWED_CLIENT_HOSTS=
|
|
54
|
-
|
|
55
|
-
########################
|
|
56
|
-
# Token Authentication #
|
|
57
|
-
########################
|
|
58
|
-
|
|
59
|
-
# Audience requirement of the current service
|
|
60
|
-
ACCESS_TOKEN_AUDIENCE=
|
|
61
|
-
|
|
62
|
-
# URL of the authorization service, serves as an issuer requirement
|
|
63
|
-
AUTH_SERVICE_URL=
|
|
64
|
-
|
|
65
|
-
PRIVATE_KEY_PATH=
|
|
66
|
-
|
|
67
|
-
#########
|
|
68
|
-
# Redis #
|
|
69
|
-
#########
|
|
70
|
-
|
|
71
|
-
# Host for redis
|
|
72
|
-
REDIS_HOST=
|
|
73
|
-
|
|
74
|
-
# Port for redis connection
|
|
75
|
-
REDIS_PORT=
|
|
76
|
-
|
|
77
|
-
# Password to connect to redis
|
|
78
|
-
REDIS_PASSWORD=
|
|
79
|
-
|
|
80
|
-
# Is redis setup as a cluster ('true'/'false')
|
|
81
|
-
REDIS_CLUSTER=
|
|
82
|
-
|
|
83
|
-
# CORS
|
|
84
|
-
CORS_ORIGIN=localhost
|
|
85
|
-
|
|
86
|
-
# IP FILTER
|
|
87
|
-
VALID_IPS='::ffff:127.0.0.1,127.0.0.1,::1'
|
|
88
|
-
|
|
89
|
-
# testing secret
|
|
90
|
-
JWT_SECRET='bad example secret'
|
|
91
|
-
|
|
92
|
-
# hmac testing secret
|
|
93
|
-
PAYLOAD_SIGNATURE_SECRET='bad signature secret'
|
|
94
|
-
|
|
95
|
-
###########
|
|
96
|
-
# Pub/Sub #
|
|
97
|
-
###########
|
|
98
|
-
|
|
99
|
-
# Google Cloud project
|
|
100
|
-
GC_PROJECT=
|
|
101
|
-
|
|
102
|
-
# Key file to connecto to Google Cloud
|
|
103
|
-
GC_KEYFILE=
|
|
104
|
-
|
|
105
|
-
# Default Pub/Sub topic
|
|
106
|
-
PUBSUB_EVENT_TOPIC=
|
|
107
|
-
|
|
108
|
-
# Pub/Sub topic for analytics
|
|
109
|
-
PUBSUB_ANALYTICS_TOPIC=
|
|
110
|
-
|
|
111
|
-
# Pub/Sub topic for cache invalidation
|
|
112
|
-
PUBSUB_CACHE_TOPIC=
|
|
113
|
-
|
|
114
|
-
# Subscriptions for the legacy topic on which model updates are propagated
|
|
115
|
-
PUBSUB_UPDATE_SUBSCRIPTION=
|
|
116
|
-
|
|
117
|
-
# secret Hash params
|
|
118
|
-
HASH_SECRET=
|
|
119
|
-
HASH_SALT=
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
##########
|
|
123
|
-
# Elastic Search #
|
|
124
|
-
##########
|
|
125
|
-
|
|
126
|
-
# The path link to Elastic Search migration data
|
|
127
|
-
ELASTIC_SEARCH_MIGRATION_PATH=
|
|
128
|
-
|
|
129
|
-
# The elastic search host url
|
|
130
|
-
ELASTIC_SEARCH_HOST=
|
|
131
|
-
|
|
132
|
-
# The elastic search user name
|
|
133
|
-
ELASTIC_SEARCH_USERNAME=''
|
|
134
|
-
|
|
135
|
-
# The elastic search password
|
|
136
|
-
ELASTIC_SEARCH_PASSWORD=''
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
###########
|
|
140
|
-
# Database #
|
|
141
|
-
###########
|
|
142
|
-
|
|
143
|
-
# Indicates whether trigger the run migrations automatically or not
|
|
144
|
-
RUN_MIGRATION=
|
|
145
|
-
|
|
146
|
-
# Indicates whether trigger the run un migrations automatically or not
|
|
147
|
-
UNDO_MIGRATION=
|
|
148
|
-
|
|
149
|
-
# Indicate the path of the directory where the datbase migrations are
|
|
150
|
-
DB_MIGRATIONS_DIR=
|
|
151
|
-
|
|
152
|
-
# Default message Audience
|
|
153
|
-
DEFAULT_MESSAGE_AUDIENCE=
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
###########
|
|
157
|
-
# SMTP Configuration #
|
|
158
|
-
###########
|
|
159
|
-
|
|
160
|
-
# The SMTP server host (e.g., smtp.gmail.com, smtp.mailtrap.io)
|
|
161
|
-
SMTP_HOST=smtp.example.com
|
|
162
|
-
|
|
163
|
-
# The SMTP port (e.g., 587 for TLS, 465 for SSL, 25 for insecure)
|
|
164
|
-
SMTP_PORT=587
|
|
165
|
-
|
|
166
|
-
# SMTP authentication username (your email address or username)
|
|
167
|
-
SMTP_USER=your-email@example.com
|
|
168
|
-
|
|
169
|
-
# SMTP authentication password (your email password or app password)
|
|
170
|
-
SMTP_PASS=your-email-password
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
FILE_STORAGE_FOLDER=./uploads
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
################
|
|
177
|
-
# User Service #
|
|
178
|
-
################
|
|
179
|
-
|
|
180
|
-
# URL where the user service is located
|
|
181
|
-
USER_SERVICE_URL=
|
|
182
|
-
|
|
183
|
-
# Attributes of the users to fetch
|
|
184
|
-
# Comma separated list of attributes to fetch from the user Service
|
|
185
|
-
# (ex: name,permissions,..) all -> for retrun everything
|
|
186
|
-
USER_FETCHED_ATTRIBUTES=
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
publish:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
|
|
12
|
-
permissions:
|
|
13
|
-
contents: write
|
|
14
|
-
id-token: write
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout code
|
|
18
|
-
uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- name: Setup Node.js
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: 20
|
|
24
|
-
registry-url: 'https://registry.npmjs.org/'
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Lint
|
|
30
|
-
run: npm run lint
|
|
31
|
-
|
|
32
|
-
# - name: Test
|
|
33
|
-
# run: npm run test
|
|
34
|
-
|
|
35
|
-
- name: Build package
|
|
36
|
-
run: npm run build --if-present
|
|
37
|
-
|
|
38
|
-
- name: Publish to npm
|
|
39
|
-
run: npm publish
|
|
40
|
-
env:
|
|
41
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierrc
DELETED
package/Dockerfile
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Instal package dependencies
|
|
2
|
-
FROM node:20 AS dependency
|
|
3
|
-
|
|
4
|
-
ARG GITHUB_TOKEN
|
|
5
|
-
ENV GITHUB_TOKEN=$GITHUB_TOKEN
|
|
6
|
-
|
|
7
|
-
WORKDIR /node
|
|
8
|
-
|
|
9
|
-
COPY package*.json ./
|
|
10
|
-
COPY .npmrc .
|
|
11
|
-
RUN npm ci
|
|
12
|
-
|
|
13
|
-
# Build source
|
|
14
|
-
FROM dependency AS base
|
|
15
|
-
COPY . .
|
|
16
|
-
|
|
17
|
-
# Build source
|
|
18
|
-
FROM base AS build
|
|
19
|
-
RUN npm run build
|
|
20
|
-
|
|
21
|
-
# Ship compiled sources
|
|
22
|
-
FROM dependency
|
|
23
|
-
|
|
24
|
-
ARG BUILD_ID
|
|
25
|
-
ENV BUILD_ID=$BUILD_ID
|
|
26
|
-
|
|
27
|
-
COPY --from=build /node/dist ./dist
|
|
28
|
-
|
|
29
|
-
RUN npm prune --production
|
|
30
|
-
|
|
31
|
-
CMD ["node", "--enable-source-maps", "-r" , "./dist/index.js"]
|