@atlantjs/backend 1.3.3 → 1.3.4
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/backend/application/databases/database-lite.config.js +1 -1
- package/backend/application/databases/database.config.js +2 -2
- package/backend/application/databases/database.helper.abstract.js +2 -2
- package/backend/application/env/load-envs.js +2 -2
- package/package.json +2 -2
- package/setup/env-var/index.js +11 -11
- package/setup/index.js +2 -2
- package/setup/server/server.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -10,7 +10,7 @@ class DatabaseLiteConfigAbstract {
|
|
|
10
10
|
const baseConfig = {
|
|
11
11
|
type: this.props.type,
|
|
12
12
|
database: this.props.binaryFilePath,
|
|
13
|
-
synchronize: arch_1.
|
|
13
|
+
synchronize: arch_1._.isFalsy((0, env_vars_1.isProdOrHomolog)()),
|
|
14
14
|
extra: {
|
|
15
15
|
cipher: "aes-256-cbc",
|
|
16
16
|
key: props.accessKey,
|
|
@@ -22,11 +22,11 @@ class DatabaseConfigAbstract {
|
|
|
22
22
|
username: this.props.username,
|
|
23
23
|
password: this.props.password,
|
|
24
24
|
database: this.props.database,
|
|
25
|
-
synchronize: arch_1.
|
|
25
|
+
synchronize: arch_1._.isFalsy((0, env_vars_1.isProdOrHomolog)()),
|
|
26
26
|
entities: [`${__dirname}/../../../../../../**/*.schema{.ts,.js}`],
|
|
27
27
|
migrations: ["./migrations/*.ts"],
|
|
28
28
|
};
|
|
29
|
-
if (arch_1.
|
|
29
|
+
if (arch_1._.isEqual(this.props.type, "aurora-mysql")) {
|
|
30
30
|
Object.assign(baseConfig, {
|
|
31
31
|
region: this.props.region ?? "",
|
|
32
32
|
secretArn: this.props.secretArn ?? "",
|
|
@@ -36,8 +36,8 @@ class DatabaseHelperAbstract {
|
|
|
36
36
|
const client = await this.openTransaction();
|
|
37
37
|
const repository = client.getRepository(schema);
|
|
38
38
|
for (const sortedEntity of sortedEntities) {
|
|
39
|
-
if (arch_1.
|
|
40
|
-
arch_1.
|
|
39
|
+
if (arch_1._.isUndefined(sortedEntity.toPersist) ||
|
|
40
|
+
arch_1._.isUndefined(sortedEntity.id)) {
|
|
41
41
|
return (0, arch_1.Failure)();
|
|
42
42
|
}
|
|
43
43
|
const registryPacked = (0, arch_1.Optional)(await repository.findOne({
|
|
@@ -9,11 +9,11 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
9
9
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
10
|
const arch_1 = require("@atlantjs/arch");
|
|
11
11
|
function loadEnvs() {
|
|
12
|
-
if (arch_1.
|
|
12
|
+
if (arch_1._.isEqual(process.env.ENVIRONMENT, arch_1.NodeEnvs.test) &&
|
|
13
13
|
!node_fs_1.default.existsSync(node_path_1.default.join(__dirname, "..", "..", "..", ".env.test"))) {
|
|
14
14
|
console.error("The .env.test file is missing with the variables and their values");
|
|
15
15
|
}
|
|
16
|
-
if (arch_1.
|
|
16
|
+
if (arch_1._.isDifferent(process.env.ENVIRONMENT, arch_1.NodeEnvs.test) &&
|
|
17
17
|
!node_fs_1.default.existsSync(node_path_1.default.join(__dirname, "..", "..", "..", "..", "..", "..", ".env"))) {
|
|
18
18
|
console.error("The .env file is missing with the variables and their values");
|
|
19
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlantjs/backend",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test:unit:cov": "yarn test:unit --coverage --runInBand"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlantjs/arch": "^
|
|
31
|
+
"@atlantjs/arch": "^5.0.0",
|
|
32
32
|
"body-parser": "^1.20.3",
|
|
33
33
|
"class-transformer": "^0.5.1",
|
|
34
34
|
"class-validator": "^0.14.1",
|
package/setup/env-var/index.js
CHANGED
|
@@ -11,7 +11,7 @@ class EnvVar {
|
|
|
11
11
|
this.variableName = name;
|
|
12
12
|
this.variableDescription = description;
|
|
13
13
|
this.enumValues = enumValues;
|
|
14
|
-
if (arch_1.
|
|
14
|
+
if (arch_1._.isEmpty(this.variableValue) && isRequired.truthy()) {
|
|
15
15
|
// TODO: Informar que a variável deve ter um valor preenchido.
|
|
16
16
|
// TODO: Disponibilizar um input para a pessoa inserir o valor na hora
|
|
17
17
|
// TODO: Caso o valor não seja válido com o typo da variável, informar e disponibilizar novamente o input
|
|
@@ -45,7 +45,7 @@ class EnvVar {
|
|
|
45
45
|
return this.variableValue;
|
|
46
46
|
}
|
|
47
47
|
static urlHttpVerify() {
|
|
48
|
-
if (arch_1.
|
|
48
|
+
if (arch_1._.isEmpty(this.variableValue)) {
|
|
49
49
|
return undefined;
|
|
50
50
|
}
|
|
51
51
|
const urlPattern = /^https?:\/\/[^\s/$.?#].[^\s]*$/i;
|
|
@@ -55,7 +55,7 @@ class EnvVar {
|
|
|
55
55
|
return this.variableValue;
|
|
56
56
|
}
|
|
57
57
|
static portNumberVerify() {
|
|
58
|
-
if (arch_1.
|
|
58
|
+
if (arch_1._.isEmpty(this.variableValue)) {
|
|
59
59
|
return undefined;
|
|
60
60
|
}
|
|
61
61
|
const portNumber = parseInt(this.variableValue, 10);
|
|
@@ -65,7 +65,7 @@ class EnvVar {
|
|
|
65
65
|
return this.variableValue;
|
|
66
66
|
}
|
|
67
67
|
static intVerify() {
|
|
68
|
-
if (arch_1.
|
|
68
|
+
if (arch_1._.isEmpty(this.variableValue)) {
|
|
69
69
|
return undefined;
|
|
70
70
|
}
|
|
71
71
|
const intValue = parseInt(this.variableValue, 10);
|
|
@@ -75,7 +75,7 @@ class EnvVar {
|
|
|
75
75
|
return intValue;
|
|
76
76
|
}
|
|
77
77
|
static floatVerify() {
|
|
78
|
-
if (arch_1.
|
|
78
|
+
if (arch_1._.isEmpty(this.variableValue)) {
|
|
79
79
|
return undefined;
|
|
80
80
|
}
|
|
81
81
|
const floatValue = parseFloat(this.variableValue);
|
|
@@ -85,27 +85,27 @@ class EnvVar {
|
|
|
85
85
|
return floatValue;
|
|
86
86
|
}
|
|
87
87
|
static arrayVerify() {
|
|
88
|
-
if (arch_1.
|
|
88
|
+
if (arch_1._.isUndefined(this.variableValue)) {
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
return this.variableValue.split(",");
|
|
92
92
|
}
|
|
93
93
|
static booleanVerify() {
|
|
94
|
-
if (arch_1.
|
|
94
|
+
if (arch_1._.isEmpty(this.variableValue)) {
|
|
95
95
|
return undefined;
|
|
96
96
|
}
|
|
97
|
-
if (arch_1.
|
|
97
|
+
if (arch_1._.isAnyOf(this.variableValue, ["false", "true"]).falsy()) {
|
|
98
98
|
throw new env_var_error_1.PickEnvError(this.variableName, this.variableDescription, `O valor da variável de ambiente ${this.variableValue} tem que ser "false" ou "true"`);
|
|
99
99
|
}
|
|
100
|
-
if (arch_1.
|
|
100
|
+
if (arch_1._.isEqual(this.variableValue, "true"))
|
|
101
101
|
return true;
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
104
|
static enumVerify() {
|
|
105
|
-
if (arch_1.
|
|
105
|
+
if (arch_1._.isUndefined(this.variableValue)) {
|
|
106
106
|
return undefined;
|
|
107
107
|
}
|
|
108
|
-
if (arch_1.
|
|
108
|
+
if (arch_1._.isUndefined(this.enumValues)) {
|
|
109
109
|
throw new env_var_error_1.PickEnvError(this.variableName, this.variableDescription, `A definição da variável de ambiente ${this.variableName} deve conter os valores de referencia do enum`);
|
|
110
110
|
}
|
|
111
111
|
if (this.enumValues.includes(this.variableValue).falsy()) {
|
package/setup/index.js
CHANGED
|
@@ -12,7 +12,7 @@ function initializeApi(props) {
|
|
|
12
12
|
(0, load_envs_1.loadEnvs)();
|
|
13
13
|
loadModules();
|
|
14
14
|
(0, dependency_injections_1.startContainer)();
|
|
15
|
-
if (arch_1.
|
|
15
|
+
if (arch_1._.isNotUndefined(props.databases)) {
|
|
16
16
|
Promise.all([
|
|
17
17
|
props.databases.map((database) => {
|
|
18
18
|
dependency_injections_1.diContainer.bind(database.token).toConstantValue(database.target);
|
|
@@ -38,7 +38,7 @@ function loadModules(modules = env_vars_1.LOAD_MODULES) {
|
|
|
38
38
|
processedModules = modules
|
|
39
39
|
.split(",")
|
|
40
40
|
.map((x) => x.trim())
|
|
41
|
-
.filter((x) => arch_1.
|
|
41
|
+
.filter((x) => arch_1._.isNotEmpty(x));
|
|
42
42
|
}
|
|
43
43
|
console.log("\n📦 Loading modules...");
|
|
44
44
|
for (const module of processedModules) {
|
package/setup/server/server.js
CHANGED
|
@@ -34,7 +34,7 @@ class Server {
|
|
|
34
34
|
console.info(LogMessage.$start_server);
|
|
35
35
|
Server.instance.listen(env_vars_1.APP_PORT, () => {
|
|
36
36
|
console.info(LogMessage.$started_server + env_vars_1.APP_PORT);
|
|
37
|
-
if (arch_1.
|
|
37
|
+
if (arch_1._.isEqual(env_vars_1.ENVIRONMENT, arch_1.NodeEnvs.development)) {
|
|
38
38
|
Server.logFooterDevelopmentMessage();
|
|
39
39
|
}
|
|
40
40
|
});
|