@atlantjs/backend 6.0.20 → 7.0.0
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/envs/env-vars.d.ts +5 -0
- package/backend/application/envs/env-vars.js +36 -0
- package/index.d.ts +2 -6
- package/index.js +4 -21
- package/package.json +4 -3
- package/setup/index.d.ts +1 -3
- package/setup/index.js +1 -1
- package/setup/server/cors-middleware.js +1 -1
- package/setup/server/server.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/backend/application/databases/database-lite.config.d.ts +0 -14
- package/backend/application/databases/database-lite.config.js +0 -23
- package/backend/application/databases/database.config.d.ts +0 -22
- package/backend/application/databases/database.config.js +0 -43
- package/backend/application/databases/database.helper.abstract.commit.failure.d.ts +0 -4
- package/backend/application/databases/database.helper.abstract.commit.failure.js +0 -14
- package/backend/application/databases/database.helper.abstract.d.ts +0 -30
- package/backend/application/databases/database.helper.abstract.delete.failure.d.ts +0 -4
- package/backend/application/databases/database.helper.abstract.delete.failure.js +0 -14
- package/backend/application/databases/database.helper.abstract.get-manager.failure.d.ts +0 -4
- package/backend/application/databases/database.helper.abstract.get-manager.failure.js +0 -14
- package/backend/application/databases/database.helper.abstract.js +0 -147
- package/backend/application/databases/database.helper.abstract.rollback.failure.d.ts +0 -4
- package/backend/application/databases/database.helper.abstract.rollback.failure.js +0 -14
- package/backend/application/databases/database.helper.abstract.write.failure.d.ts +0 -4
- package/backend/application/databases/database.helper.abstract.write.failure.js +0 -14
- package/backend/application/env/env-vars.d.ts +0 -15
- package/backend/application/env/env-vars.js +0 -92
- package/setup/parchment/parchment.d.ts +0 -5
- package/setup/parchment/parchment.error.d.ts +0 -3
- package/setup/parchment/parchment.error.js +0 -9
- package/setup/parchment/parchment.js +0 -71
- package/setup/parchment/parchment.type.d.ts +0 -9
- package/setup/parchment/parchment.type.js +0 -2
- /package/backend/application/{env → envs}/load-envs.d.ts +0 -0
- /package/backend/application/{env → envs}/load-envs.js +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DataSource, DatabaseType } from "typeorm";
|
|
2
|
-
interface DatabaseLiteConfigProps {
|
|
3
|
-
type: DatabaseType;
|
|
4
|
-
binaryFilePath: string;
|
|
5
|
-
accessKey: string;
|
|
6
|
-
schemaPaths: string[];
|
|
7
|
-
migrationPaths: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare abstract class DatabaseLiteConfigAbstract {
|
|
10
|
-
private readonly props;
|
|
11
|
-
configs: DataSource;
|
|
12
|
-
constructor(props: DatabaseLiteConfigProps);
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseLiteConfigAbstract = void 0;
|
|
4
|
-
const typeorm_1 = require("typeorm");
|
|
5
|
-
const env_vars_1 = require("../env/env-vars");
|
|
6
|
-
class DatabaseLiteConfigAbstract {
|
|
7
|
-
constructor(props) {
|
|
8
|
-
this.props = props;
|
|
9
|
-
const baseConfig = {
|
|
10
|
-
type: this.props.type,
|
|
11
|
-
database: this.props.binaryFilePath,
|
|
12
|
-
synchronize: env_vars_1.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
|
|
13
|
-
extra: {
|
|
14
|
-
cipher: "aes-256-cbc",
|
|
15
|
-
key: props.accessKey,
|
|
16
|
-
},
|
|
17
|
-
entities: props.schemaPaths,
|
|
18
|
-
migrations: props.migrationPaths,
|
|
19
|
-
};
|
|
20
|
-
this.configs = new typeorm_1.DataSource(baseConfig);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.DatabaseLiteConfigAbstract = DatabaseLiteConfigAbstract;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DataSource, DatabaseType } from "typeorm";
|
|
2
|
-
interface DatabaseConfigProps {
|
|
3
|
-
type: DatabaseType;
|
|
4
|
-
host: string;
|
|
5
|
-
port: number;
|
|
6
|
-
adminUser: string;
|
|
7
|
-
adminPassword: string;
|
|
8
|
-
name: string;
|
|
9
|
-
schemaName: string;
|
|
10
|
-
schemaPaths: string[];
|
|
11
|
-
migrationPaths: string[];
|
|
12
|
-
region?: string;
|
|
13
|
-
secretArn?: string;
|
|
14
|
-
resourceArn?: string;
|
|
15
|
-
}
|
|
16
|
-
export declare abstract class DatabaseConfigAbstract {
|
|
17
|
-
private readonly props;
|
|
18
|
-
configs: DataSource;
|
|
19
|
-
private readonly sslConfig;
|
|
20
|
-
constructor(props: DatabaseConfigProps);
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseConfigAbstract = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
const typeorm_1 = require("typeorm");
|
|
6
|
-
const env_vars_1 = require("../env/env-vars");
|
|
7
|
-
class DatabaseConfigAbstract {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
this.props = props;
|
|
10
|
-
this.sslConfig = {
|
|
11
|
-
ssl: true,
|
|
12
|
-
extra: {
|
|
13
|
-
ssl: {
|
|
14
|
-
rejectUnauthorized: false,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
const baseConfig = {
|
|
19
|
-
type: this.props.type,
|
|
20
|
-
host: this.props.host,
|
|
21
|
-
port: this.props.port,
|
|
22
|
-
username: this.props.adminUser,
|
|
23
|
-
password: this.props.adminPassword,
|
|
24
|
-
database: this.props.name,
|
|
25
|
-
schema: this.props.schemaName,
|
|
26
|
-
synchronize: env_vars_1.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
|
|
27
|
-
entities: this.props.schemaPaths,
|
|
28
|
-
migrations: this.props.migrationPaths,
|
|
29
|
-
};
|
|
30
|
-
if (arch_1._.isEqual(this.props.type, "aurora-mysql")) {
|
|
31
|
-
Object.assign(baseConfig, {
|
|
32
|
-
region: this.props.region ?? "",
|
|
33
|
-
secretArn: this.props.secretArn ?? "",
|
|
34
|
-
resourceArn: this.props.resourceArn ?? "",
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (env_vars_1.DATABASE_SSL_ENABLED) {
|
|
38
|
-
Object.assign(baseConfig, this.sslConfig);
|
|
39
|
-
}
|
|
40
|
-
this.configs = new typeorm_1.DataSource(baseConfig);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.DatabaseConfigAbstract = DatabaseConfigAbstract;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstractCommitFailure = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
class DatabaseHelperAbstractCommitFailure extends arch_1.FailureAbstract {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super({
|
|
8
|
-
failureClass: DatabaseHelperAbstractCommitFailure,
|
|
9
|
-
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
|
-
stackTrace: error,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseHelperAbstractCommitFailure = DatabaseHelperAbstractCommitFailure;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { FailureAbstract, Newable, Optional, Return, SolidAbstract, VertexAbstract } from "@atlantjs/arch";
|
|
2
|
-
import { DataSource, EntityTarget, FindOptionsRelations, ObjectLiteral } from "typeorm";
|
|
3
|
-
import { DatabaseLiteConfigAbstract } from "./database-lite.config";
|
|
4
|
-
import { DatabaseConfigAbstract } from "./database.config";
|
|
5
|
-
interface FaceEntity {
|
|
6
|
-
face: EntityTarget<ObjectLiteral>;
|
|
7
|
-
entity: SolidAbstract | VertexAbstract;
|
|
8
|
-
}
|
|
9
|
-
interface FaceEntityReturn {
|
|
10
|
-
face: EntityTarget<ObjectLiteral>;
|
|
11
|
-
id: string;
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class DatabaseHelperAbstract {
|
|
14
|
-
private database;
|
|
15
|
-
private queryRunner;
|
|
16
|
-
connect(db: DatabaseConfigAbstract | DatabaseLiteConfigAbstract): Promise<DataSource>;
|
|
17
|
-
disconnect(): Promise<void>;
|
|
18
|
-
read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(face: T, condition: {
|
|
19
|
-
[K in keyof InstanceType<T>]?: InstanceType<T>[K];
|
|
20
|
-
}, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureAbstract>>;
|
|
21
|
-
write(faceEntities: FaceEntity[]): Promise<Return<FaceEntityReturn[], FailureAbstract>>;
|
|
22
|
-
delete<T extends Newable<ObjectLiteral>>(schema: T, condition: {
|
|
23
|
-
[K in keyof InstanceType<T>]?: InstanceType<T>[K];
|
|
24
|
-
}, isSoft?: boolean): Promise<Return<undefined, FailureAbstract>>;
|
|
25
|
-
private getManager;
|
|
26
|
-
private openTransaction;
|
|
27
|
-
private commit;
|
|
28
|
-
private rollback;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstractDeleteFailure = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
class DatabaseHelperAbstractDeleteFailure extends arch_1.FailureAbstract {
|
|
6
|
-
constructor(isSoft, error) {
|
|
7
|
-
super({
|
|
8
|
-
failureClass: DatabaseHelperAbstractDeleteFailure,
|
|
9
|
-
message: `Failed to ${isSoft.truthy() ? "soft" : "hard"} delete the record in the database`,
|
|
10
|
-
stackTrace: error,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseHelperAbstractDeleteFailure = DatabaseHelperAbstractDeleteFailure;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstractGetManagerFailure = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
class DatabaseHelperAbstractGetManagerFailure extends arch_1.FailureAbstract {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super({
|
|
8
|
-
failureClass: DatabaseHelperAbstractGetManagerFailure,
|
|
9
|
-
message: "The database is not connected",
|
|
10
|
-
stackTrace: error,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseHelperAbstractGetManagerFailure = DatabaseHelperAbstractGetManagerFailure;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstract = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
const database_helper_abstract_commit_failure_1 = require("./database.helper.abstract.commit.failure");
|
|
6
|
-
const database_helper_abstract_delete_failure_1 = require("./database.helper.abstract.delete.failure");
|
|
7
|
-
const database_helper_abstract_get_manager_failure_1 = require("./database.helper.abstract.get-manager.failure");
|
|
8
|
-
const database_helper_abstract_rollback_failure_1 = require("./database.helper.abstract.rollback.failure");
|
|
9
|
-
const database_helper_abstract_write_failure_1 = require("./database.helper.abstract.write.failure");
|
|
10
|
-
class DatabaseHelperAbstract {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.database = arch_1.Nothing;
|
|
13
|
-
this.queryRunner = arch_1.Nothing;
|
|
14
|
-
}
|
|
15
|
-
async connect(db) {
|
|
16
|
-
this.database = (0, arch_1.Optional)(db.configs);
|
|
17
|
-
await this.database.unpack().initialize();
|
|
18
|
-
return this.database.unpack();
|
|
19
|
-
}
|
|
20
|
-
async disconnect() {
|
|
21
|
-
await this.database.unpack().destroy();
|
|
22
|
-
this.database = arch_1.Nothing;
|
|
23
|
-
}
|
|
24
|
-
async read(face, condition, relations) {
|
|
25
|
-
const clientWrapped = this.getManager();
|
|
26
|
-
if (clientWrapped.hasFailure())
|
|
27
|
-
return (0, arch_1.Failure)(clientWrapped.unwrapFail());
|
|
28
|
-
const client = clientWrapped.unwrap();
|
|
29
|
-
const repository = client.getRepository(face);
|
|
30
|
-
const registryPacked = (0, arch_1.Optional)((await repository.find({
|
|
31
|
-
where: { ...condition, deleted: false },
|
|
32
|
-
relations,
|
|
33
|
-
})));
|
|
34
|
-
if (relations && registryPacked.hasSomething()) {
|
|
35
|
-
const filterDeletedRelations = (face, rels) => {
|
|
36
|
-
if (!face || typeof face !== "object" || !rels)
|
|
37
|
-
return;
|
|
38
|
-
for (const rel of rels) {
|
|
39
|
-
const relValue = face[rel];
|
|
40
|
-
if (Array.isArray(relValue)) {
|
|
41
|
-
face[rel] = relValue.filter((item) => !item?.deleted);
|
|
42
|
-
}
|
|
43
|
-
else if (relValue.deleted) {
|
|
44
|
-
face[rel] = undefined;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
for (const faces of registryPacked.unpack()) {
|
|
49
|
-
filterDeletedRelations(faces, relations);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return (0, arch_1.Success)(registryPacked);
|
|
53
|
-
}
|
|
54
|
-
async write(faceEntities) {
|
|
55
|
-
try {
|
|
56
|
-
const client = await this.openTransaction();
|
|
57
|
-
const ids = [];
|
|
58
|
-
for (const faceEntity of faceEntities) {
|
|
59
|
-
const repository = client.getRepository(faceEntity.face);
|
|
60
|
-
if (arch_1._.isUndefined(faceEntity.entity.toPersist) ||
|
|
61
|
-
arch_1._.isUndefined(faceEntity.entity.id)) {
|
|
62
|
-
return (0, arch_1.Failure)(new database_helper_abstract_write_failure_1.DatabaseHelperAbstractWriteFailure());
|
|
63
|
-
}
|
|
64
|
-
const registryFoundedPacked = (0, arch_1.Optional)(await repository.findOne({
|
|
65
|
-
where: {
|
|
66
|
-
id: faceEntity.entity.id.toString(),
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
if (registryFoundedPacked.hasNothing()) {
|
|
70
|
-
await repository.save(faceEntity.entity.toPersist());
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
await repository.update({ id: faceEntity.entity.id.toString() }, faceEntity.entity.toPersist());
|
|
74
|
-
}
|
|
75
|
-
ids.push({
|
|
76
|
-
face: faceEntity.face,
|
|
77
|
-
id: faceEntity.entity.id.toString(),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
await this.commit();
|
|
81
|
-
return (0, arch_1.Success)(ids);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
await this.rollback();
|
|
85
|
-
return (0, arch_1.Failure)(new database_helper_abstract_write_failure_1.DatabaseHelperAbstractWriteFailure(error));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async delete(schema, condition, isSoft = true) {
|
|
89
|
-
try {
|
|
90
|
-
const client = await this.openTransaction();
|
|
91
|
-
const repository = client.getRepository(schema);
|
|
92
|
-
const registriesPacked = (0, arch_1.Optional)(await repository.find({ where: condition }));
|
|
93
|
-
if (registriesPacked.hasNothing()) {
|
|
94
|
-
return (0, arch_1.Failure)(new database_helper_abstract_delete_failure_1.DatabaseHelperAbstractDeleteFailure(isSoft));
|
|
95
|
-
}
|
|
96
|
-
if (isSoft.falsy()) {
|
|
97
|
-
repository.delete(condition);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
const registries = registriesPacked.unpack();
|
|
101
|
-
for (const registry of registries) {
|
|
102
|
-
registry.deleted = true;
|
|
103
|
-
await repository.update({ id: registry.id.toString() }, registry);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
await this.commit();
|
|
107
|
-
return (0, arch_1.Success)();
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
await this.rollback();
|
|
111
|
-
return (0, arch_1.Failure)(new database_helper_abstract_delete_failure_1.DatabaseHelperAbstractDeleteFailure(isSoft, error));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
getManager() {
|
|
115
|
-
if (this.database.hasNothing()) {
|
|
116
|
-
return (0, arch_1.Failure)(new database_helper_abstract_get_manager_failure_1.DatabaseHelperAbstractGetManagerFailure());
|
|
117
|
-
}
|
|
118
|
-
return (0, arch_1.Success)(this.database.unpack().manager);
|
|
119
|
-
}
|
|
120
|
-
async openTransaction() {
|
|
121
|
-
if (this.queryRunner.hasNothing()) {
|
|
122
|
-
this.queryRunner = (0, arch_1.Optional)(this.database.unpack().createQueryRunner());
|
|
123
|
-
await this.queryRunner.unpack().connect();
|
|
124
|
-
await this.queryRunner.unpack().startTransaction();
|
|
125
|
-
}
|
|
126
|
-
return this.queryRunner.unpack().manager;
|
|
127
|
-
}
|
|
128
|
-
async commit() {
|
|
129
|
-
if (this.queryRunner.hasNothing()) {
|
|
130
|
-
return (0, arch_1.Failure)(new database_helper_abstract_commit_failure_1.DatabaseHelperAbstractCommitFailure());
|
|
131
|
-
}
|
|
132
|
-
await this.queryRunner.unpack().commitTransaction();
|
|
133
|
-
await this.queryRunner.unpack().release();
|
|
134
|
-
this.queryRunner = arch_1.Nothing;
|
|
135
|
-
return (0, arch_1.Success)();
|
|
136
|
-
}
|
|
137
|
-
async rollback() {
|
|
138
|
-
if (this.queryRunner.hasNothing()) {
|
|
139
|
-
return (0, arch_1.Failure)(new database_helper_abstract_rollback_failure_1.DatabaseHelperAbstractRollbackFailure());
|
|
140
|
-
}
|
|
141
|
-
await this.queryRunner.unpack().rollbackTransaction();
|
|
142
|
-
await this.queryRunner.unpack().release();
|
|
143
|
-
this.queryRunner = arch_1.Nothing;
|
|
144
|
-
return (0, arch_1.Success)();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.DatabaseHelperAbstract = DatabaseHelperAbstract;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstractRollbackFailure = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
class DatabaseHelperAbstractRollbackFailure extends arch_1.FailureAbstract {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super({
|
|
8
|
-
failureClass: DatabaseHelperAbstractRollbackFailure,
|
|
9
|
-
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
|
-
stackTrace: error,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseHelperAbstractRollbackFailure = DatabaseHelperAbstractRollbackFailure;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseHelperAbstractWriteFailure = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
class DatabaseHelperAbstractWriteFailure extends arch_1.FailureAbstract {
|
|
6
|
-
constructor(error) {
|
|
7
|
-
super({
|
|
8
|
-
failureClass: DatabaseHelperAbstractWriteFailure,
|
|
9
|
-
message: "Failed to insert or update the record in the database",
|
|
10
|
-
stackTrace: error,
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.DatabaseHelperAbstractWriteFailure = DatabaseHelperAbstractWriteFailure;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NodeEnvs } from "@atlantjs/arch";
|
|
2
|
-
import { DatabaseType } from "typeorm";
|
|
3
|
-
export declare const DATABASE_TYPE: DatabaseType;
|
|
4
|
-
export declare const DATABASE_NAME: string;
|
|
5
|
-
export declare const DATABASE_DEFAULT_SCHEMA: string;
|
|
6
|
-
export declare const DATABASE_HOST: string;
|
|
7
|
-
export declare const DATABASE_ADMIN_PASSWORD: string;
|
|
8
|
-
export declare const DATABASE_PORT: number;
|
|
9
|
-
export declare const DATABASE_ADMIN_USER: string;
|
|
10
|
-
export declare const DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED: boolean;
|
|
11
|
-
export declare const DATABASE_SSL_ENABLED: boolean;
|
|
12
|
-
export declare const APP_PORT: number;
|
|
13
|
-
export declare const LOAD_MODULES: string[];
|
|
14
|
-
export declare const CORS_ALLOWED_ORIGINS: string;
|
|
15
|
-
export declare const ENVIRONMENT: NodeEnvs;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENVIRONMENT = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.DATABASE_SSL_ENABLED = exports.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED = exports.DATABASE_ADMIN_USER = exports.DATABASE_PORT = exports.DATABASE_ADMIN_PASSWORD = exports.DATABASE_HOST = exports.DATABASE_DEFAULT_SCHEMA = exports.DATABASE_NAME = exports.DATABASE_TYPE = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
const parchment_1 = require("../../../setup/parchment/parchment");
|
|
6
|
-
exports.DATABASE_TYPE = parchment_1.Parchment.verse({
|
|
7
|
-
name: "DATABASE_TYPE",
|
|
8
|
-
type: "enum",
|
|
9
|
-
description: "The type of the database",
|
|
10
|
-
default: "postgres",
|
|
11
|
-
values: ["aurora-postgres", "postgres", "sqlite"],
|
|
12
|
-
isRequired: true,
|
|
13
|
-
});
|
|
14
|
-
exports.DATABASE_NAME = parchment_1.Parchment.verse({
|
|
15
|
-
name: "DATABASE_NAME",
|
|
16
|
-
type: "text",
|
|
17
|
-
description: "The name of the database",
|
|
18
|
-
isRequired: true,
|
|
19
|
-
});
|
|
20
|
-
exports.DATABASE_DEFAULT_SCHEMA = parchment_1.Parchment.verse({
|
|
21
|
-
name: "DATABASE_DEFAULT_SCHEMA",
|
|
22
|
-
type: "text",
|
|
23
|
-
description: "The name of default schema the database",
|
|
24
|
-
isRequired: true,
|
|
25
|
-
});
|
|
26
|
-
exports.DATABASE_HOST = parchment_1.Parchment.verse({
|
|
27
|
-
name: "DATABASE_HOST",
|
|
28
|
-
description: "The host address of the database server",
|
|
29
|
-
type: "text",
|
|
30
|
-
isRequired: true,
|
|
31
|
-
});
|
|
32
|
-
exports.DATABASE_ADMIN_PASSWORD = parchment_1.Parchment.verse({
|
|
33
|
-
name: "DATABASE_ADMIN_PASSWORD",
|
|
34
|
-
description: "The password for the database user",
|
|
35
|
-
type: "text",
|
|
36
|
-
isRequired: true,
|
|
37
|
-
});
|
|
38
|
-
exports.DATABASE_PORT = parchment_1.Parchment.verse({
|
|
39
|
-
name: "DATABASE_PORT",
|
|
40
|
-
type: "port-number",
|
|
41
|
-
description: "The port number on which the database server is running",
|
|
42
|
-
isRequired: true,
|
|
43
|
-
});
|
|
44
|
-
exports.DATABASE_ADMIN_USER = parchment_1.Parchment.verse({
|
|
45
|
-
name: "DATABASE_ADMIN_USER",
|
|
46
|
-
description: "The username for the database database",
|
|
47
|
-
type: "text",
|
|
48
|
-
isRequired: true,
|
|
49
|
-
});
|
|
50
|
-
exports.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED = parchment_1.Parchment.verse({
|
|
51
|
-
name: "DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED",
|
|
52
|
-
type: "boolean",
|
|
53
|
-
description: "Flag indicating whether the ORM automatically creates tables in the database based on .schema.ts files",
|
|
54
|
-
isRequired: true,
|
|
55
|
-
});
|
|
56
|
-
exports.DATABASE_SSL_ENABLED = parchment_1.Parchment.verse({
|
|
57
|
-
name: "DATABASE_SSL_ENABLED",
|
|
58
|
-
type: "boolean",
|
|
59
|
-
description: "Flag indicating whether the database requires an SSL connection",
|
|
60
|
-
isRequired: true,
|
|
61
|
-
});
|
|
62
|
-
exports.APP_PORT = parchment_1.Parchment.verse({
|
|
63
|
-
name: "APP_PORT",
|
|
64
|
-
type: "port-number",
|
|
65
|
-
description: "The port number on which the application will run",
|
|
66
|
-
isRequired: true,
|
|
67
|
-
});
|
|
68
|
-
exports.LOAD_MODULES = parchment_1.Parchment.verse({
|
|
69
|
-
name: "LOAD_MODULES",
|
|
70
|
-
type: "array",
|
|
71
|
-
description: "List of modules, separated by commas, to be loaded by the application",
|
|
72
|
-
isRequired: true,
|
|
73
|
-
});
|
|
74
|
-
exports.CORS_ALLOWED_ORIGINS = parchment_1.Parchment.verse({
|
|
75
|
-
name: "CORS_ALLOWED_ORIGINS",
|
|
76
|
-
default: "*",
|
|
77
|
-
description: "Allowed origins for CORS",
|
|
78
|
-
type: "text",
|
|
79
|
-
isRequired: true,
|
|
80
|
-
});
|
|
81
|
-
exports.ENVIRONMENT = parchment_1.Parchment.verse({
|
|
82
|
-
name: "ENVIRONMENT",
|
|
83
|
-
type: "enum",
|
|
84
|
-
isRequired: true,
|
|
85
|
-
values: [
|
|
86
|
-
arch_1.NodeEnvs.test,
|
|
87
|
-
arch_1.NodeEnvs.development,
|
|
88
|
-
arch_1.NodeEnvs.production,
|
|
89
|
-
arch_1.NodeEnvs.homolog,
|
|
90
|
-
],
|
|
91
|
-
description: "The current environment in which the application is running",
|
|
92
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PickEnvError = void 0;
|
|
4
|
-
class PickEnvError extends Error {
|
|
5
|
-
constructor(variableName, variableDescription, messageError) {
|
|
6
|
-
super(`\n❯ ${process.env.ENVIRONMENT} - ${messageError}:\n\n - ${variableName}: ${variableDescription}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.PickEnvError = PickEnvError;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Parchment = void 0;
|
|
4
|
-
const arch_1 = require("@atlantjs/arch");
|
|
5
|
-
const parchment_error_1 = require("./parchment.error");
|
|
6
|
-
class Parchment {
|
|
7
|
-
static verse({ ...verse }) {
|
|
8
|
-
const setValue = process.env[verse.name] || verse.default?.toString();
|
|
9
|
-
if (arch_1._.isNullOrUndefined(setValue) && verse.isRequired.truthy()) {
|
|
10
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, "The environment variable must have its value defined");
|
|
11
|
-
}
|
|
12
|
-
return Parchment.convertSetValue(verse, setValue);
|
|
13
|
-
}
|
|
14
|
-
static convertSetValue(verse, value) {
|
|
15
|
-
if (arch_1._.isUndefined(value)) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
if (verse.type === "array") {
|
|
19
|
-
return value.split(",");
|
|
20
|
-
}
|
|
21
|
-
if (verse.type === "boolean") {
|
|
22
|
-
if (arch_1._.isAnyOf(value, ["false", "true"]).falsy()) {
|
|
23
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `The value of the environment variable ${value} must be "false" or "true"`);
|
|
24
|
-
}
|
|
25
|
-
return arch_1._.isEqual(value, "true");
|
|
26
|
-
}
|
|
27
|
-
if (verse.type === "enum") {
|
|
28
|
-
if (arch_1._.isUndefined(verse.values)) {
|
|
29
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `A definição da variável de ambiente ${verse.name} deve conter os valores de referencia`);
|
|
30
|
-
}
|
|
31
|
-
if (verse.values.includes(value).falsy()) {
|
|
32
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `A variável ${verse.name} deve conter algum dos seguintes valores: [${verse.values.join(", ")}]`);
|
|
33
|
-
}
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
if (verse.type === "float") {
|
|
37
|
-
const floatValue = Number.parseFloat(value);
|
|
38
|
-
if (Number.isNaN(floatValue)) {
|
|
39
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `The value of the environment variable ${verse.name} must be a valid float number`);
|
|
40
|
-
}
|
|
41
|
-
return floatValue;
|
|
42
|
-
}
|
|
43
|
-
if (verse.type === "int") {
|
|
44
|
-
const intValue = Number.parseInt(value, 10);
|
|
45
|
-
if (Number.isNaN(intValue)) {
|
|
46
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `O valor da variável de ambiente ${verse.name} deve ser um número inteiro válido`);
|
|
47
|
-
}
|
|
48
|
-
return intValue;
|
|
49
|
-
}
|
|
50
|
-
if (verse.type === "port-number") {
|
|
51
|
-
const portNumber = Number.parseInt(value, 10);
|
|
52
|
-
if (Number.isNaN(portNumber) || portNumber < 1 || portNumber > 65535) {
|
|
53
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `O valor da variável de ambiente ${verse.name} deve ser um número de porta válido entre 1 e 65535`);
|
|
54
|
-
}
|
|
55
|
-
return portNumber;
|
|
56
|
-
}
|
|
57
|
-
if (verse.type === "text") {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
if (verse.type === "url-https") {
|
|
61
|
-
const urlPattern = /^https?:\/\/[^\s/$.?#].[^\s]*$/i;
|
|
62
|
-
if (!urlPattern.test(value)) {
|
|
63
|
-
throw new parchment_error_1.PickEnvError(verse.name, verse.description, `O valor da variável de ambiente ${verse.name} deve ser uma URL válida começando com http ou https`);
|
|
64
|
-
}
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
// If none of the types matched, return undefined
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.Parchment = Parchment;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type VerseTypes = "text" | "port-number" | "array" | "enum" | "url-https" | "int" | "boolean" | "float";
|
|
2
|
-
export interface PickVerseType<VerseType> {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
type: VerseTypes;
|
|
6
|
-
values?: string[];
|
|
7
|
-
isRequired: boolean;
|
|
8
|
-
default?: VerseType;
|
|
9
|
-
}
|
|
File without changes
|
|
File without changes
|