@atlantjs/backend 1.0.0 → 1.0.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/backend/application/databases/database.config.d.ts +23 -0
- package/backend/application/databases/database.config.js +41 -0
- package/backend/application/databases/database.helper.abstract.commit.failure.d.ts +4 -0
- package/backend/application/databases/database.helper.abstract.commit.failure.js +14 -0
- package/backend/application/databases/database.helper.abstract.d.ts +22 -0
- package/backend/application/databases/database.helper.abstract.get-manager.failure.d.ts +4 -0
- package/backend/application/databases/database.helper.abstract.get-manager.failure.js +14 -0
- package/backend/application/databases/database.helper.abstract.js +104 -0
- package/backend/application/databases/database.helper.abstract.rollback.failure.d.ts +4 -0
- package/backend/application/databases/database.helper.abstract.rollback.failure.js +14 -0
- package/{setup → backend/application}/env/env-vars.d.ts +0 -3
- package/{setup → backend/application}/env/env-vars.js +1 -13
- package/backend/application/injections.abstract.d.ts +11 -0
- package/backend/application/injections.abstract.js +45 -0
- package/backend/application/injections.abstract.type.d.ts +21 -0
- package/backend/application/injections.abstract.type.js +2 -0
- package/backend/domain/entities/entity-backend.abstract.d.ts +9 -0
- package/backend/domain/entities/entity-backend.abstract.js +11 -0
- package/backend/domain/middlewares/middleware.handler.abstract.d.ts +4 -0
- package/backend/domain/middlewares/middleware.handler.abstract.js +6 -0
- package/backend/domain/providers/provider.abstract.d.ts +2 -0
- package/backend/domain/providers/provider.abstract.js +6 -0
- package/backend/domain/repositories/repository.abstract.d.ts +2 -0
- package/backend/domain/repositories/repository.abstract.js +6 -0
- package/backend/domain/services/service.abstract.d.ts +2 -0
- package/backend/domain/services/service.abstract.js +6 -0
- package/backend/domain/usecases/usecase.abstract.d.ts +4 -0
- package/backend/domain/usecases/usecase.abstract.js +6 -0
- package/backend/infrastructure/controllers/controller.abstract.d.ts +8 -0
- package/backend/infrastructure/controllers/controller.abstract.js +13 -0
- package/backend/infrastructure/controllers/payloads/payload.abstract.d.ts +2 -0
- package/backend/infrastructure/controllers/payloads/payload.abstract.js +6 -0
- package/backend/infrastructure/controllers/payloads/validators/validator.abstract.d.ts +2 -0
- package/backend/infrastructure/controllers/payloads/validators/validator.abstract.js +6 -0
- package/backend/infrastructure/controllers/responses/response.abstract.d.ts +4 -0
- package/backend/infrastructure/controllers/responses/response.abstract.js +6 -0
- package/backend/infrastructure/repositories/schemas/schema.abstract.d.ts +7 -0
- package/backend/infrastructure/repositories/schemas/schema.abstract.js +43 -0
- package/index.d.ts +23 -2
- package/index.js +47 -6
- package/package.json +2 -2
- package/setup/dependency-injections/di-container.abstract.d.ts +7 -1
- package/setup/index.d.ts +4 -2
- package/setup/index.js +2 -2
- package/setup/server/cors-middleware.js +1 -1
- package/setup/server/server.js +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- /package/{setup → backend/application}/env/load-envs.d.ts +0 -0
- /package/{setup → backend/application}/env/load-envs.js +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DataSource, DatabaseType } from "typeorm";
|
|
2
|
+
interface DatabaseConfigProps {
|
|
3
|
+
type: DatabaseType;
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
database: string;
|
|
9
|
+
schema: string;
|
|
10
|
+
synchronize: boolean;
|
|
11
|
+
entities: string[];
|
|
12
|
+
migrations: string[];
|
|
13
|
+
region?: string;
|
|
14
|
+
secretArn?: string;
|
|
15
|
+
resourceArn?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class DatabaseConfigAbstract {
|
|
18
|
+
private readonly props;
|
|
19
|
+
configs: DataSource;
|
|
20
|
+
private readonly productionOrHomologConfigs;
|
|
21
|
+
constructor(props: DatabaseConfigProps);
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
class DatabaseConfigAbstract {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
this.props = props;
|
|
9
|
+
this.productionOrHomologConfigs = {
|
|
10
|
+
ssl: true,
|
|
11
|
+
extra: {
|
|
12
|
+
ssl: {
|
|
13
|
+
rejectUnauthorized: false,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const baseConfig = {
|
|
18
|
+
type: this.props.type,
|
|
19
|
+
host: this.props.host,
|
|
20
|
+
port: this.props.port,
|
|
21
|
+
username: this.props.username,
|
|
22
|
+
password: this.props.password,
|
|
23
|
+
database: this.props.database,
|
|
24
|
+
synchronize: arch_1.Guardian.isFalsy((0, arch_1.isProdOrHomolog)()),
|
|
25
|
+
entities: [`${__dirname}/../../**/*.schema{.ts,.js}`],
|
|
26
|
+
migrations: ["./migrations/*.ts"],
|
|
27
|
+
};
|
|
28
|
+
if (arch_1.Guardian.isEqual(this.props.type, "aurora-mysql")) {
|
|
29
|
+
Object.assign(baseConfig, {
|
|
30
|
+
region: this.props.region ?? "",
|
|
31
|
+
secretArn: this.props.secretArn ?? "",
|
|
32
|
+
resourceArn: this.props.resourceArn ?? "",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (new arch_1.UrlAbstract(this.props.host).has("@")) {
|
|
36
|
+
Object.assign(baseConfig, this.productionOrHomologConfigs);
|
|
37
|
+
}
|
|
38
|
+
this.configs = new typeorm_1.DataSource(baseConfig);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.DatabaseConfigAbstract = DatabaseConfigAbstract;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
className: DatabaseHelperAbstractCommitFailure.name,
|
|
9
|
+
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractCommitFailure = DatabaseHelperAbstractCommitFailure;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DatabaseConfigAbstract } from "./database.config";
|
|
2
|
+
import { EntityAbstract } from "../../domain/entities/entity-backend.abstract";
|
|
3
|
+
import { Optional, Newable, Return, FailureAbstract } from "@atlantjs/arch";
|
|
4
|
+
import { DataSource, ObjectLiteral } from "typeorm";
|
|
5
|
+
import { FindOptionsRelations } from "typeorm";
|
|
6
|
+
export declare abstract class DatabaseHelperAbstract {
|
|
7
|
+
private database;
|
|
8
|
+
private queryRunner;
|
|
9
|
+
connect(db: DatabaseConfigAbstract): Promise<DataSource>;
|
|
10
|
+
disconnect(): Promise<void>;
|
|
11
|
+
read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(schema: T, condition: {
|
|
12
|
+
[K in keyof InstanceType<T>]?: InstanceType<T>[K];
|
|
13
|
+
}, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureAbstract>>;
|
|
14
|
+
write<T extends Newable<ObjectLiteral>>(schema: T, sortedEntities: EntityAbstract[]): Promise<Return<undefined, undefined>>;
|
|
15
|
+
delete<T extends Newable<ObjectLiteral>>(entity: T, condition: {
|
|
16
|
+
[K in keyof InstanceType<T>]?: InstanceType<T>[K];
|
|
17
|
+
}): Promise<Return<undefined, undefined>>;
|
|
18
|
+
private getManager;
|
|
19
|
+
private openTransaction;
|
|
20
|
+
private commit;
|
|
21
|
+
private rollback;
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
className: DatabaseHelperAbstractGetManagerFailure.name,
|
|
9
|
+
message: "The database is not connected",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractGetManagerFailure = DatabaseHelperAbstractGetManagerFailure;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseHelperAbstract = void 0;
|
|
4
|
+
const database_helper_abstract_commit_failure_1 = require("./database.helper.abstract.commit.failure");
|
|
5
|
+
const database_helper_abstract_get_manager_failure_1 = require("./database.helper.abstract.get-manager.failure");
|
|
6
|
+
const database_helper_abstract_rollback_failure_1 = require("./database.helper.abstract.rollback.failure");
|
|
7
|
+
const arch_1 = require("@atlantjs/arch");
|
|
8
|
+
class DatabaseHelperAbstract {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.database = arch_1.Nothing;
|
|
11
|
+
this.queryRunner = arch_1.Nothing;
|
|
12
|
+
}
|
|
13
|
+
async connect(db) {
|
|
14
|
+
this.database = (0, arch_1.Optional)(db.configs);
|
|
15
|
+
await this.database.unpack().initialize();
|
|
16
|
+
return this.database.unpack();
|
|
17
|
+
}
|
|
18
|
+
async disconnect() {
|
|
19
|
+
await this.database.unpack().destroy();
|
|
20
|
+
this.database = arch_1.Nothing;
|
|
21
|
+
}
|
|
22
|
+
async read(schema, condition, relations) {
|
|
23
|
+
const clientWrapped = this.getManager();
|
|
24
|
+
if (clientWrapped.hasFailure())
|
|
25
|
+
return (0, arch_1.Failure)(clientWrapped.unwrapFail());
|
|
26
|
+
const client = clientWrapped.unwrap();
|
|
27
|
+
const repository = client.getRepository(schema);
|
|
28
|
+
const registryPacked = (0, arch_1.Optional)((await repository.find({
|
|
29
|
+
where: condition,
|
|
30
|
+
relations,
|
|
31
|
+
})));
|
|
32
|
+
return (0, arch_1.Success)(registryPacked);
|
|
33
|
+
}
|
|
34
|
+
async write(schema, sortedEntities) {
|
|
35
|
+
try {
|
|
36
|
+
const client = await this.openTransaction();
|
|
37
|
+
const repository = client.getRepository(schema);
|
|
38
|
+
sortedEntities.forEach(async (sortedEntity) => {
|
|
39
|
+
if (arch_1.Guardian.isUndefined(sortedEntity.toPersist) ||
|
|
40
|
+
arch_1.Guardian.isUndefined(sortedEntity.id)) {
|
|
41
|
+
return (0, arch_1.Failure)();
|
|
42
|
+
}
|
|
43
|
+
const registryPacked = (0, arch_1.Optional)(await repository.findOne({
|
|
44
|
+
where: { id: sortedEntity.id.toString() },
|
|
45
|
+
}));
|
|
46
|
+
if (registryPacked.hasNothing()) {
|
|
47
|
+
await repository.save(sortedEntity.toPersist());
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toPersist());
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
await this.commit();
|
|
54
|
+
return (0, arch_1.Success)();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
await this.rollback();
|
|
58
|
+
return (0, arch_1.Failure)();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async delete(entity, condition) {
|
|
62
|
+
const client = await this.openTransaction();
|
|
63
|
+
const repository = client.getRepository(entity);
|
|
64
|
+
const registryPacked = (0, arch_1.Optional)(await repository.find({ where: condition }));
|
|
65
|
+
if (registryPacked.hasNothing()) {
|
|
66
|
+
return (0, arch_1.Failure)();
|
|
67
|
+
}
|
|
68
|
+
repository.delete(condition);
|
|
69
|
+
return (0, arch_1.Success)();
|
|
70
|
+
}
|
|
71
|
+
getManager() {
|
|
72
|
+
if (this.database.hasNothing()) {
|
|
73
|
+
return (0, arch_1.Failure)(new database_helper_abstract_get_manager_failure_1.DatabaseHelperAbstractGetManagerFailure());
|
|
74
|
+
}
|
|
75
|
+
return (0, arch_1.Success)(this.database.unpack().manager);
|
|
76
|
+
}
|
|
77
|
+
async openTransaction() {
|
|
78
|
+
if (this.queryRunner.hasNothing()) {
|
|
79
|
+
this.queryRunner = (0, arch_1.Optional)(this.database.unpack().createQueryRunner());
|
|
80
|
+
await this.queryRunner.unpack().connect();
|
|
81
|
+
await this.queryRunner.unpack().startTransaction();
|
|
82
|
+
}
|
|
83
|
+
return this.queryRunner.unpack().manager;
|
|
84
|
+
}
|
|
85
|
+
async commit() {
|
|
86
|
+
if (this.queryRunner.hasNothing()) {
|
|
87
|
+
return (0, arch_1.Failure)(new database_helper_abstract_commit_failure_1.DatabaseHelperAbstractCommitFailure());
|
|
88
|
+
}
|
|
89
|
+
await this.queryRunner.unpack().commitTransaction();
|
|
90
|
+
await this.queryRunner.unpack().release();
|
|
91
|
+
this.queryRunner = arch_1.Nothing;
|
|
92
|
+
return (0, arch_1.Success)();
|
|
93
|
+
}
|
|
94
|
+
async rollback() {
|
|
95
|
+
if (this.queryRunner.hasNothing()) {
|
|
96
|
+
return (0, arch_1.Failure)(new database_helper_abstract_rollback_failure_1.DatabaseHelperAbstractRollbackFailure());
|
|
97
|
+
}
|
|
98
|
+
await this.queryRunner.unpack().rollbackTransaction();
|
|
99
|
+
await this.queryRunner.unpack().release();
|
|
100
|
+
this.queryRunner = arch_1.Nothing;
|
|
101
|
+
return (0, arch_1.Success)();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.DatabaseHelperAbstract = DatabaseHelperAbstract;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
className: DatabaseHelperAbstractRollbackFailure.name,
|
|
9
|
+
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractRollbackFailure = DatabaseHelperAbstractRollbackFailure;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { NodeEnvs } from "@atlantjs/arch";
|
|
2
|
-
export declare const ENVIRONMENT: NodeEnvs;
|
|
3
1
|
export declare const IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256: string | undefined;
|
|
4
2
|
export declare const APP_PORT: number;
|
|
5
3
|
export declare const LOAD_MODULES: string[];
|
|
6
4
|
export declare const CORS_ALLOWED_ORIGINS: string;
|
|
7
|
-
export declare const isProdOrHomolog: () => boolean;
|
|
@@ -3,18 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const arch_1 = require("@atlantjs/arch");
|
|
6
|
+
exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256 = void 0;
|
|
8
7
|
const env_var_1 = __importDefault(require("env-var"));
|
|
9
|
-
exports.ENVIRONMENT = env_var_1.default
|
|
10
|
-
.get("ENVIRONMENT")
|
|
11
|
-
.required()
|
|
12
|
-
.asEnum([
|
|
13
|
-
arch_1.NodeEnvs.test,
|
|
14
|
-
arch_1.NodeEnvs.development,
|
|
15
|
-
arch_1.NodeEnvs.production,
|
|
16
|
-
arch_1.NodeEnvs.homolog,
|
|
17
|
-
]);
|
|
18
8
|
exports.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256 = env_var_1.default
|
|
19
9
|
.get("KEYCLOAK_MOVINGAPP_REALM_PUBLIC_KEY_RS256")
|
|
20
10
|
.asString();
|
|
@@ -24,5 +14,3 @@ exports.CORS_ALLOWED_ORIGINS = env_var_1.default
|
|
|
24
14
|
.get("CORS_ALLOWED_ORIGINS")
|
|
25
15
|
.default("*")
|
|
26
16
|
.asString();
|
|
27
|
-
const isProdOrHomolog = () => [arch_1.NodeEnvs.homolog, arch_1.NodeEnvs.production].includes(exports.ENVIRONMENT);
|
|
28
|
-
exports.isProdOrHomolog = isProdOrHomolog;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Injections } from "./injections.abstract.type";
|
|
2
|
+
export declare abstract class InjectionsAbstract {
|
|
3
|
+
protected abstract _injections: Injections;
|
|
4
|
+
constructor();
|
|
5
|
+
private injectControllers;
|
|
6
|
+
private injectMiddlewares;
|
|
7
|
+
private injectUsecases;
|
|
8
|
+
private injectServices;
|
|
9
|
+
private injectRepositories;
|
|
10
|
+
private injectProviders;
|
|
11
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectionsAbstract = void 0;
|
|
4
|
+
const dependency_injections_1 = require("../../setup/dependency-injections");
|
|
5
|
+
class InjectionsAbstract {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.injectControllers();
|
|
8
|
+
this.injectMiddlewares();
|
|
9
|
+
this.injectUsecases();
|
|
10
|
+
this.injectServices();
|
|
11
|
+
this.injectRepositories();
|
|
12
|
+
this.injectProviders();
|
|
13
|
+
}
|
|
14
|
+
injectControllers() {
|
|
15
|
+
this._injections.controllers?.map((controller) => {
|
|
16
|
+
dependency_injections_1.diContainer.bind(controller).toSelf();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
injectMiddlewares() {
|
|
20
|
+
this._injections.middlewares?.map((middleware) => {
|
|
21
|
+
dependency_injections_1.diContainer.bind(middleware).toSelf();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
injectUsecases() {
|
|
25
|
+
this._injections.usecases?.map((usecase) => {
|
|
26
|
+
dependency_injections_1.diContainer.bind(usecase.ref).to(usecase.target);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
injectServices() {
|
|
30
|
+
this._injections.services?.map((service) => {
|
|
31
|
+
dependency_injections_1.diContainer.bind(service.ref).to(service.target);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
injectRepositories() {
|
|
35
|
+
this._injections.repositories?.map((repository) => {
|
|
36
|
+
dependency_injections_1.diContainer.bind(repository.ref).to(repository.target);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
injectProviders() {
|
|
40
|
+
this._injections.providers?.map((provider) => {
|
|
41
|
+
dependency_injections_1.diContainer.bind(provider.ref).to(provider.target);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.InjectionsAbstract = InjectionsAbstract;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Newable } from "@atlantjs/arch";
|
|
2
|
+
import { interfaces } from "inversify";
|
|
3
|
+
import { ControllerAbstract } from "../infrastructure/controllers/controller.abstract";
|
|
4
|
+
import { MiddlewareHandlerAbstract } from "../domain/middlewares/middleware.handler.abstract";
|
|
5
|
+
import { RepositoryAbstract } from "../domain/repositories/repository.abstract";
|
|
6
|
+
import { ServiceAbstract } from "../domain/services/service.abstract";
|
|
7
|
+
import { UsecaseAbstract } from "../domain/usecases/usecase.abstract";
|
|
8
|
+
type ServiceIdentifier<T> = interfaces.ServiceIdentifier<T>;
|
|
9
|
+
interface BindTo<T> {
|
|
10
|
+
ref: ServiceIdentifier<unknown>;
|
|
11
|
+
target: Newable<T>;
|
|
12
|
+
}
|
|
13
|
+
export interface Injections {
|
|
14
|
+
controllers?: ServiceIdentifier<ControllerAbstract>[];
|
|
15
|
+
middlewares?: ServiceIdentifier<MiddlewareHandlerAbstract>[];
|
|
16
|
+
usecases?: BindTo<UsecaseAbstract>[];
|
|
17
|
+
services?: BindTo<ServiceAbstract>[];
|
|
18
|
+
repositories?: BindTo<RepositoryAbstract>[];
|
|
19
|
+
providers?: BindTo<RepositoryAbstract>[];
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SchemaAbstract } from "../../infrastructure/repositories/schemas/schema.abstract";
|
|
2
|
+
import { UuidAbstract } from "@atlantjs/arch";
|
|
3
|
+
import { SolidAbstract } from "@atlantjs/arch/arch/modules/domain/entities/solid.abstract";
|
|
4
|
+
export declare abstract class EntityAbstract extends SolidAbstract {
|
|
5
|
+
protected _id: UuidAbstract;
|
|
6
|
+
constructor(_id: UuidAbstract);
|
|
7
|
+
abstract get id(): UuidAbstract;
|
|
8
|
+
abstract toPersist(): SchemaAbstract;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityAbstract = void 0;
|
|
4
|
+
const solid_abstract_1 = require("@atlantjs/arch/arch/modules/domain/entities/solid.abstract");
|
|
5
|
+
class EntityAbstract extends solid_abstract_1.SolidAbstract {
|
|
6
|
+
constructor(_id) {
|
|
7
|
+
super();
|
|
8
|
+
this._id = _id;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.EntityAbstract = EntityAbstract;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResponseAbstract } from "./responses/response.abstract";
|
|
2
|
+
import { HttpStatusCodes, FailureAbstract } from "@atlantjs/arch";
|
|
3
|
+
import { Response } from "express";
|
|
4
|
+
export declare abstract class ControllerAbstract {
|
|
5
|
+
abstract handler(response: Response, ...args: unknown[]): Promise<Response>;
|
|
6
|
+
protected onSuccess<Payload extends ResponseAbstract>(response: Response, payload?: Payload, httpStatusCode?: HttpStatusCodes): Response;
|
|
7
|
+
protected onFailure(response: Response, failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerAbstract = void 0;
|
|
4
|
+
const arch_1 = require("@atlantjs/arch");
|
|
5
|
+
class ControllerAbstract {
|
|
6
|
+
onSuccess(response, payload, httpStatusCode = arch_1.HttpStatusCodes.OK) {
|
|
7
|
+
return response.status(httpStatusCode).send(payload?.toPlain() ?? {});
|
|
8
|
+
}
|
|
9
|
+
onFailure(response, failure, httpStatusCode = arch_1.HttpStatusCodes.BAD_REQUEST) {
|
|
10
|
+
return response.status(httpStatusCode).send(failure.toPlain());
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ControllerAbstract = ControllerAbstract;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SchemaAbstract = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
class SchemaAbstract extends typeorm_1.BaseEntity {
|
|
15
|
+
beforeInsert() {
|
|
16
|
+
this.createdAt = new Date(Date.now());
|
|
17
|
+
this.updatedAt = new Date(Date.now());
|
|
18
|
+
}
|
|
19
|
+
beforeUpdate() {
|
|
20
|
+
this.updatedAt = new Date(Date.now());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SchemaAbstract = SchemaAbstract;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ name: "createdAt", type: "date" }),
|
|
26
|
+
__metadata("design:type", Date)
|
|
27
|
+
], SchemaAbstract.prototype, "createdAt", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ name: "updatedAt", type: "date" }),
|
|
30
|
+
__metadata("design:type", Date)
|
|
31
|
+
], SchemaAbstract.prototype, "updatedAt", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.BeforeInsert)(),
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", []),
|
|
36
|
+
__metadata("design:returntype", void 0)
|
|
37
|
+
], SchemaAbstract.prototype, "beforeInsert", null);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.BeforeUpdate)(),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", []),
|
|
42
|
+
__metadata("design:returntype", void 0)
|
|
43
|
+
], SchemaAbstract.prototype, "beforeUpdate", null);
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { DatabaseConfigAbstract } from "./backend/application/databases/database.config";
|
|
2
|
+
export { DatabaseHelperAbstract } from "./backend/application/databases/database.helper.abstract";
|
|
3
|
+
export { IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256, APP_PORT, LOAD_MODULES, CORS_ALLOWED_ORIGINS, } from "./backend/application/env/env-vars";
|
|
4
|
+
export { InjectionsAbstract } from "./backend/application/injections.abstract";
|
|
5
|
+
export { EntityAbstract } from "./backend/domain/entities/entity-backend.abstract";
|
|
6
|
+
export { MiddlewareHandlerAbstract } from "./backend/domain/middlewares/middleware.handler.abstract";
|
|
7
|
+
export { ProviderAbstract } from "./backend/domain/providers/provider.abstract";
|
|
8
|
+
export { RepositoryAbstract } from "./backend/domain/repositories/repository.abstract";
|
|
9
|
+
export { ServiceAbstract } from "./backend/domain/services/service.abstract";
|
|
10
|
+
export { UsecaseAbstract } from "./backend/domain/usecases/usecase.abstract";
|
|
11
|
+
export { ControllerAbstract } from "./backend/infrastructure/controllers/controller.abstract";
|
|
12
|
+
export { PayloadAbstract } from "./backend/infrastructure/controllers/payloads/payload.abstract";
|
|
13
|
+
export { ValidatorAbstract } from "./backend/infrastructure/controllers/payloads/validators/validator.abstract";
|
|
14
|
+
export { ResponseAbstract } from "./backend/infrastructure/controllers/responses/response.abstract";
|
|
15
|
+
export { SchemaAbstract } from "./backend/infrastructure/repositories/schemas/schema.abstract";
|
|
16
|
+
export { startContainer, diContainer } from "./setup/dependency-injections";
|
|
17
|
+
export { DefaultContainer } from "./setup/dependency-injections/default-container";
|
|
18
|
+
export { DiContainerAbstract } from "./setup/dependency-injections/di-container.abstract";
|
|
19
|
+
export { BodyParserMiddleware } from "./setup/server/body-parser-middleware";
|
|
20
|
+
export { CorsMiddleware } from "./setup/server/cors-middleware";
|
|
21
|
+
export { DefaultErrorHandlerMiddleware } from "./setup/server/default-error-handler-middleware";
|
|
22
|
+
export { Server } from "http";
|
|
23
|
+
export { Container } from "inversify";
|
|
2
24
|
export { initializeApi, synthesizePaths } from "./setup";
|
|
3
|
-
export { diContainer } from "./setup/dependency-injections";
|