@zanobijs/core 1.0.0-beta.2 → 1.0.0-beta.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +199 -5
  3. package/exceptions/constant.message.d.ts +1 -0
  4. package/exceptions/constant.message.js +8 -1
  5. package/exceptions/resolution.exception.d.ts +13 -0
  6. package/exceptions/resolution.exception.js +25 -0
  7. package/factory.d.ts +5 -1
  8. package/factory.js +22 -2
  9. package/index.d.ts +1 -0
  10. package/index.js +1 -0
  11. package/injector/injector.d.ts +6 -0
  12. package/injector/injector.js +25 -0
  13. package/injector/module.d.ts +1 -0
  14. package/injector/module.js +21 -3
  15. package/interfaces/factory.interface.d.ts +4 -0
  16. package/interfaces/factory.interface.js +2 -0
  17. package/interfaces/index.d.ts +1 -0
  18. package/{__test__/mocks → interfaces}/index.js +1 -1
  19. package/package.json +3 -4
  20. package/tsconfig.build.json +1 -1
  21. package/__test__/factory.spec.d.ts +0 -1
  22. package/__test__/factory.spec.js +0 -33
  23. package/__test__/factory.spec.ts +0 -37
  24. package/__test__/injector/injector.spec.d.ts +0 -1
  25. package/__test__/injector/injector.spec.js +0 -32
  26. package/__test__/injector/injector.spec.ts +0 -32
  27. package/__test__/injector/module.spec.d.ts +0 -1
  28. package/__test__/injector/module.spec.js +0 -60
  29. package/__test__/injector/module.spec.ts +0 -66
  30. package/__test__/metadata.spec.d.ts +0 -1
  31. package/__test__/metadata.spec.js +0 -70
  32. package/__test__/metadata.spec.ts +0 -71
  33. package/__test__/mocks/classModule.mock.d.ts +0 -10
  34. package/__test__/mocks/classModule.mock.js +0 -74
  35. package/__test__/mocks/classModule.mock.ts +0 -55
  36. package/__test__/mocks/classWithDependeciesClass.mock.d.ts +0 -13
  37. package/__test__/mocks/classWithDependeciesClass.mock.js +0 -40
  38. package/__test__/mocks/classWithDependeciesClass.mock.ts +0 -21
  39. package/__test__/mocks/classWithDependeciesInject.mock.d.ts +0 -24
  40. package/__test__/mocks/classWithDependeciesInject.mock.js +0 -74
  41. package/__test__/mocks/classWithDependeciesInject.mock.ts +0 -47
  42. package/__test__/mocks/index.d.ts +0 -1
  43. package/__test__/mocks/index.ts +0 -1
  44. package/exceptions/constant.message.ts +0 -1
  45. package/exceptions/index.ts +0 -2
  46. package/exceptions/invalid.module.exception.ts +0 -16
  47. package/factory.ts +0 -69
  48. package/index.ts +0 -2
  49. package/injector/index.ts +0 -2
  50. package/injector/injector.ts +0 -89
  51. package/injector/module.ts +0 -149
  52. package/interface/index.d.ts +0 -0
  53. package/interface/index.js +0 -1
  54. package/interface/index.ts +0 -1
  55. package/metadata.ts +0 -178
  56. package/tsconfig.build.tsbuildinfo +0 -1
  57. package/tsconfig.json +0 -11
package/CHANGELOG.md CHANGED
@@ -3,6 +3,6 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [1.0.0-beta.2](https://github.com/devdroide/ZanobiJS/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2023-11-08)
6
+ # [1.0.0-beta.4](https://github.com/devdroide/ZanobiJS/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2024-04-12)
7
7
 
8
8
  **Note:** Version bump only for package @zanobijs/core
package/README.md CHANGED
@@ -1,11 +1,205 @@
1
- # `core`
1
+ <p align="center">
2
+ <a href="https://zanobijs.vercel.app/" target="blank"><img src="https://zanobijs.vercel.app/_astro/ZanobiHero.__7I9OCQ_ZkaY1J.webp" width="120" alt="ZanobiJS Logo" /></a>
3
+ </p>
2
4
 
3
- > TODO: description
5
+ <H1 align="center">Welcome to ZanobiJS</H1>
4
6
 
5
- ## Usage
7
+ [![npm](https://img.shields.io/badge/npm-v1.0.0-darkorange.svg)](https://www.npmjs.com/package/@zanobijs/cli)
8
+ [![coverage](https://img.shields.io/badge/coverage-98-green.svg)](https://mochajs.org/)
9
+ [![test](https://img.shields.io/badge/test-mocha-CC0000.svg)](https://mochajs.org/)
10
+ [![nodejs](https://img.shields.io/badge/nodejs->=16.0.0-darkgreen.svg)](https://nodejs.org)
11
+ [![typescrit](https://img.shields.io/badge/TS->=5.2.2-darkblue.svg)](https://www.typescriptlang.org/)
12
+ [![licence](https://img.shields.io/badge/licence-MIT-purple.svg)](https://en.wikipedia.org/wiki/MIT_License)
13
+ [![Doc](https://img.shields.io/badge/ZNB-Documentation-blue.svg)](https://zanobijs.vercel.app/)
6
14
 
15
+ It is a mini-framework for Node.js that allows you to build server-side microservices in an efficient and scalable way. It is designed to be small and efficient, but powerful enough for enterprise applications. ZanobiJS is written in TypeScript and JavaScript, giving you the flexibility to choose the language you prefer.
16
+ ## Features
17
+
18
+ - Small and efficient.
19
+ - Written in TypeScript/JavaScript.
20
+ - Ideal for building server-side microservices.
21
+ - Optimized scalability and performance.
22
+
23
+ ## Getting started
24
+
25
+ If you want to consult the [guide](https://zanobijs.vercel.app/en/) and learn about the project, visit [zanobijs.vercel.app](https://zanobijs.vercel.app/en/)
26
+
27
+ ## Installation
28
+
29
+ Install my-project with npm
30
+
31
+ ```bash
32
+ npm install @zanobijs/common @zanobijs/core
7
33
  ```
8
- const core = require('core');
34
+
35
+ ## Directories
36
+
37
+ ├── ...
38
+ ├── example # Feature example
39
+ │ ├── example.controller.ts # Controller
40
+ | ├── example.service.ts # Service
41
+ ├── app.module.ts # Main Module
42
+ ├── index.ts # Handler or bootstrap
43
+ └── ...
44
+ ## Usage/Examples
45
+
46
+ ### example.service.ts
47
+
48
+ ```javascript
49
+ import { Inject, Injectable } from "@zanobijs/common";
50
+
51
+ @Injectable()
52
+ export class ServiceExample {
53
+ constructor(
54
+ @Inject("API_CLIENT") private apiClient: string,
55
+ @Inject("API_KEY") private apiKey: string
56
+ ) {}
57
+ getHello() {
58
+ return "Hello ServiceExample";
59
+ }
60
+ getApiClient(){
61
+ return this.apiClient
62
+ }
63
+ getApiKey(){
64
+ return this.apiKey
65
+ }
66
+ }
9
67
 
10
- // TODO: DEMONSTRATE API
11
68
  ```
69
+ ### example.controller.ts
70
+
71
+ ```javascript
72
+ import { Controller, Inject } from "@zanobijs/common";
73
+ import { ServiceExample } from "./example.service";
74
+
75
+ @Controller()
76
+ export class ControllerExample {
77
+ constructor(
78
+ private sExample: ServiceExample,
79
+ @Inject("API_URL") private apiUrl: string
80
+ ) {
81
+ this.apiUrl = apiUrl;
82
+ }
83
+
84
+ getApiUrl() {
85
+ return this.apiUrl;
86
+ }
87
+ getHelloService() {
88
+ return this.sExample.getHello();
89
+ }
90
+ getClienteService() {
91
+ return this.sExample.getApiClient();
92
+ }
93
+ getKeyService() {
94
+ return this.sExample.getApiKey();
95
+ }
96
+ }
97
+ ```
98
+ ### AppModule.ts
99
+
100
+ ```javascript
101
+ import { Module } from "@zanobijs/common";
102
+ import { ControllerExample } from "./example/example.controller";
103
+ import { ServiceExample } from "./example/example.service";
104
+
105
+ @Module({
106
+ imports: [],
107
+ controllers: [ControllerExample],
108
+ services: [
109
+ ServiceExample,
110
+ {
111
+ provider: "API_URL",
112
+ useValue: "https://url.com",
113
+ },
114
+ {
115
+ provider: "API_KEY",
116
+ useValue: "myKey12345API",
117
+ },
118
+ {
119
+ provider: "API_CLIENT",
120
+ useValue: "thisClientAPI",
121
+ },
122
+ ],
123
+ exports: [],
124
+ })
125
+ export class AppModule {}
126
+
127
+ ```
128
+
129
+ ### Index.ts
130
+
131
+ ```javascript
132
+ import { Factory } from "@zanobijs/core";
133
+ import { AppModule } from "./app.module";
134
+ import { ControllerExample } from "./example/example.controller";
135
+
136
+
137
+ const bootstrap = () => {
138
+ const factory = new Factory(AppModule);
139
+ const app = factory.create();
140
+ const controllerExample = app.get<ControllerExample>(
141
+ "controllerExample"
142
+ );
143
+ console.log(controllerExample.getHelloService());
144
+ console.log(controllerExample.getApiUrl());
145
+ console.log(controllerExample.getClienteService());
146
+ console.log(controllerExample.getKeyService());
147
+ }
148
+ bootstrap();
149
+ // Hello ServiceExample
150
+ // https://url.com
151
+ // thisClientAPI
152
+ // myKey12345API
153
+ ```
154
+ > [!Note]
155
+ > It can also be used in [AWS lambda](https://zanobijs.vercel.app/en/01-getting-started/first-step/#setting), see how to do it in the [guide](https://zanobijs.vercel.app/en/01-getting-started/first-step/#setting)
156
+
157
+ ## Use Logger
158
+
159
+ - Import logger service of @zanobij/common/utils.
160
+ - Define whether the record is visible. [Default is false]
161
+ - Get the service.
162
+ - Use the different events (success, info, warn, error, debug).
163
+
164
+ ```javascript
165
+ // Index.ts - This is important for the operation
166
+ const factory = new Factory(AppModule, {
167
+ activeLoggerUser: true
168
+ });
169
+
170
+ // use en services controllers, etc
171
+
172
+ import { LoggerUser } from "@zanobijs/common/utils";
173
+
174
+ const logUser = LoggerUser();
175
+
176
+ logUser.success("Lorem ipsum success");
177
+ logUser.info("Lorem ipsum info");
178
+ logUser.warn("Lorem ipsum warn");
179
+ logUser.error("Lorem ipsum error");
180
+ logUser.debug("Lorem ipsum debug");
181
+
182
+ // ***** PRINT *****
183
+ // [SUCCESS]: Lorem ipsum success <green print>
184
+ // [INFO]: Lorem ipsum info <blue print>
185
+ // [WARN]: Lorem ipsum warn <yellow print>
186
+ // [ERROR]: Lorem ipsum error <red print>
187
+ // [DEBUG]: Lorem ipsum debug <white print>
188
+
189
+ ```
190
+ ## Authors
191
+
192
+ - [@devdroide](https://www.github.com/devdroide)
193
+
194
+
195
+ ## Credits
196
+
197
+ ZanobiJS is heavily inspired by [NestJS](https://nestjs.com/) and [AngularJS](https://angularjs.org/).
198
+
199
+ Additionally, it is used [Awilix](https://github.com/jeffijoe/awilix#readme) which is a container for Extremely powerful and effective dependency injection.
200
+
201
+ Finally, it is an effort that we make and that we hope can help in the construction of projects.
202
+
203
+ ## License
204
+
205
+ Private - Read License
@@ -1 +1,2 @@
1
1
  export declare const MODULE_INVALID_ANNOTATION_ERROR: () => string;
2
+ export declare const CONTAINER_RESOLUTION_ERROR: (entity: string) => string;
@@ -1,5 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODULE_INVALID_ANNOTATION_ERROR = void 0;
3
+ exports.CONTAINER_RESOLUTION_ERROR = exports.MODULE_INVALID_ANNOTATION_ERROR = void 0;
4
4
  const MODULE_INVALID_ANNOTATION_ERROR = () => `The class must have an annotation @Module()`;
5
5
  exports.MODULE_INVALID_ANNOTATION_ERROR = MODULE_INVALID_ANNOTATION_ERROR;
6
+ const CONTAINER_RESOLUTION_ERROR = (entity) => `'${entity}' is not registered in any @module.`;
7
+ exports.CONTAINER_RESOLUTION_ERROR = CONTAINER_RESOLUTION_ERROR;
8
+ // export const CONTAINER_RESOLUTION_INJECT_ERROR = (
9
+ // entity: string,
10
+ // targetName: any,
11
+ // ) =>
12
+ // `'@Inject(${entity})' was not found in any loaded @module. Check the "${targetName}" file`;
@@ -0,0 +1,13 @@
1
+ import { RuntimeException } from "@zanobijs/common/exceptions/runtime.exception";
2
+ /**
3
+ * Excepción lanzada cuando se intenta obtener una entidad
4
+ * (importar, controlador, servicio o exportar) que no fue
5
+ * declarada en `@Module` de @zanobijs/common
6
+ *
7
+ * @remarks
8
+ * Esta clase extiende la base `RuntimeException`de @zanobijs/core
9
+ * para proporcionar detalles adicionales del error.
10
+ */
11
+ export declare class ContainerResolutionException extends RuntimeException {
12
+ constructor(entity: string, detail: any);
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContainerResolutionException = void 0;
4
+ const runtime_exception_1 = require("@zanobijs/common/exceptions/runtime.exception");
5
+ const constant_message_1 = require("./constant.message");
6
+ /**
7
+ * Excepción lanzada cuando se intenta obtener una entidad
8
+ * (importar, controlador, servicio o exportar) que no fue
9
+ * declarada en `@Module` de @zanobijs/common
10
+ *
11
+ * @remarks
12
+ * Esta clase extiende la base `RuntimeException`de @zanobijs/core
13
+ * para proporcionar detalles adicionales del error.
14
+ */
15
+ class ContainerResolutionException extends runtime_exception_1.RuntimeException {
16
+ constructor(entity, detail) {
17
+ super((0, constant_message_1.CONTAINER_RESOLUTION_ERROR)(entity), detail);
18
+ }
19
+ }
20
+ exports.ContainerResolutionException = ContainerResolutionException;
21
+ // export class ContainerInjectResolutionException extends RuntimeException {
22
+ // constructor(entity: string, targetName: any, detail: any = ``) {
23
+ // super(CONTAINER_RESOLUTION_INJECT_ERROR(entity, targetName), detail);
24
+ // }
25
+ // }
package/factory.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import "reflect-metadata";
2
+ import { IFactoryOptions } from "./interfaces";
2
3
  /**
3
4
  * Factory es una clase que facilita la creación y configuración de
4
5
  * contenedores de inyección de dependencias utilizando metadatos y
@@ -9,7 +10,9 @@ export declare class Factory {
9
10
  private moduleHandler;
10
11
  private registeredClasses;
11
12
  private container;
12
- constructor(appModule: any);
13
+ private logger;
14
+ private options;
15
+ constructor(appModule: any, options?: IFactoryOptions);
13
16
  /**
14
17
  * Este método registra clases desde el módulo proporcionado
15
18
  * y recorre sus importaciones de forma recursiva para registrar
@@ -34,4 +37,5 @@ export declare class Factory {
34
37
  * @returns {any} - Instancia resuelta.
35
38
  */
36
39
  get<T>(entity: string): T;
40
+ evaluateOptions(): void;
37
41
  }
package/factory.js CHANGED
@@ -4,6 +4,8 @@ exports.Factory = void 0;
4
4
  require("reflect-metadata");
5
5
  const awilix_1 = require("awilix");
6
6
  const module_1 = require("./injector/module");
7
+ const resolution_exception_1 = require("./exceptions/resolution.exception");
8
+ const utils_1 = require("@zanobijs/common/utils");
7
9
  /**
8
10
  * Factory es una clase que facilita la creación y configuración de
9
11
  * contenedores de inyección de dependencias utilizando metadatos y
@@ -14,7 +16,12 @@ class Factory {
14
16
  moduleHandler;
15
17
  registeredClasses = {};
16
18
  container;
17
- constructor(appModule) {
19
+ logger;
20
+ options;
21
+ constructor(appModule, options = {}) {
22
+ this.options = options;
23
+ this.evaluateOptions();
24
+ this.logger = (0, utils_1.Logger)();
18
25
  this.moduleHandler = new module_1.Module();
19
26
  this.registerClassesFromModule(appModule);
20
27
  }
@@ -50,6 +57,7 @@ class Factory {
50
57
  create() {
51
58
  this.container = (0, awilix_1.createContainer)({ injectionMode: awilix_1.InjectionMode.CLASSIC });
52
59
  this.container.register(this.registeredClasses);
60
+ this.logger.info("Registered Classes", this.registeredClasses);
53
61
  return this;
54
62
  }
55
63
  /**
@@ -58,7 +66,19 @@ class Factory {
58
66
  * @returns {any} - Instancia resuelta.
59
67
  */
60
68
  get(entity) {
61
- return this.container.resolve(entity);
69
+ try {
70
+ return this.container.resolve(entity);
71
+ }
72
+ catch (error) {
73
+ this.logger.info("Error resolving entity: ", error.message + "\n");
74
+ throw new resolution_exception_1.ContainerResolutionException(entity, error.message);
75
+ }
76
+ }
77
+ evaluateOptions() {
78
+ if (this.options.activeLoggerSystem)
79
+ process.env.ZANOBIJS_LOGGER = "true";
80
+ if (this.options.activeLoggerUser)
81
+ process.env.ZANOBIJS_LOGGER = "true";
62
82
  }
63
83
  }
64
84
  exports.Factory = Factory;
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Factory } from './factory';
2
2
  export * from "./injector";
3
+ export * from "./interfaces";
package/index.js CHANGED
@@ -5,3 +5,4 @@ const tslib_1 = require("tslib");
5
5
  var factory_1 = require("./factory");
6
6
  Object.defineProperty(exports, "Factory", { enumerable: true, get: function () { return factory_1.Factory; } });
7
7
  tslib_1.__exportStar(require("./injector"), exports);
8
+ tslib_1.__exportStar(require("./interfaces"), exports);
@@ -10,6 +10,8 @@ export declare class Injector {
10
10
  private listProviders;
11
11
  private metadata;
12
12
  private logger;
13
+ private registeredClassParentModule;
14
+ private moduleName;
13
15
  /**
14
16
  * En Constructor de la clase Injector obtenermos las instancias
15
17
  * de Metadata y Logger e inciamos el escaneo de proveedores.
@@ -24,6 +26,7 @@ export declare class Injector {
24
26
  * @private
25
27
  */
26
28
  private scanProviders;
29
+ setRegisteredClassParentModule(registerClass: any): void;
27
30
  /**
28
31
  * Método para obtener un objeto con los parámetros y valores
29
32
  * que se inyectarán en la clase (target).
@@ -54,7 +57,10 @@ export declare class Injector {
54
57
  name?: string;
55
58
  lifetime?: import("awilix").LifetimeType;
56
59
  register?: (...args: any[]) => import("awilix").Resolver<object>;
60
+ isLeakSafe?: boolean;
57
61
  dispose?: import("awilix").Disposer<object>;
58
62
  disposer(dispose: import("awilix").Disposer<object>): import("awilix").BuildResolver<object> & import("awilix").DisposableResolver<object>;
59
63
  };
64
+ getAllProvider(): Map<any, any>;
65
+ getInjectProvider(provider: any): import("awilix").Resolver<any>;
60
66
  }
@@ -14,6 +14,8 @@ class Injector {
14
14
  listProviders = new Map();
15
15
  metadata;
16
16
  logger;
17
+ registeredClassParentModule = {};
18
+ moduleName = "";
17
19
  /**
18
20
  * En Constructor de la clase Injector obtenermos las instancias
19
21
  * de Metadata y Logger e inciamos el escaneo de proveedores.
@@ -23,6 +25,7 @@ class Injector {
23
25
  constructor(module) {
24
26
  this.metadata = metadata_1.Metadata.getInstance();
25
27
  this.logger = (0, utils_1.Logger)();
28
+ this.moduleName = module.name;
26
29
  this.module = module;
27
30
  this.scanProviders();
28
31
  }
@@ -40,6 +43,9 @@ class Injector {
40
43
  });
41
44
  this.logger.debug("Injector - list provider", this.listProviders);
42
45
  }
46
+ setRegisteredClassParentModule(registerClass) {
47
+ this.registeredClassParentModule = registerClass;
48
+ }
43
49
  /**
44
50
  * Método para obtener un objeto con los parámetros y valores
45
51
  * que se inyectarán en la clase (target).
@@ -58,6 +64,17 @@ class Injector {
58
64
  const useValue = this.listProviders.get(key);
59
65
  injectData[paramName] = useValue;
60
66
  }
67
+ else {
68
+ if (key in this.registeredClassParentModule) {
69
+ this.logger.info(`"${key}" is on registered Class in Parent Module.`);
70
+ const paramName = dInject.get(key);
71
+ injectData[paramName] = (0, awilix_1.aliasTo)(key);
72
+ }
73
+ else {
74
+ this.logger.important(`It is injecting @INJECT('${key}') provider in '${target.name}' but is not registered in '${this.moduleName}' or in previously loaded @modules`);
75
+ // throw new ContainerInjectResolutionException(key, target.name);
76
+ }
77
+ }
61
78
  }
62
79
  }
63
80
  return injectData;
@@ -79,5 +96,13 @@ class Injector {
79
96
  interface: target,
80
97
  };
81
98
  }
99
+ getAllProvider() {
100
+ return this.listProviders;
101
+ }
102
+ getInjectProvider(provider) {
103
+ return typeof provider.value === "function"
104
+ ? (0, awilix_1.asFunction)(provider.value).scoped()
105
+ : (0, awilix_1.asValue)(provider.value);
106
+ }
82
107
  }
83
108
  exports.Injector = Injector;
@@ -63,6 +63,7 @@ export declare class Module {
63
63
  * contructor(private sA: ServiceA) // parametro con nombre diferente
64
64
  */
65
65
  private registerDependenciesToAlias;
66
+ private registerAllProviders;
66
67
  /**
67
68
  * Devuelve las importaciones del módulo.
68
69
  * @returns {any[] | undefined} - Importaciones del módulo.
@@ -45,6 +45,8 @@ class Module {
45
45
  */
46
46
  initialize() {
47
47
  this.getMetadataModule();
48
+ this.registerAllProviders();
49
+ this.injector.setRegisteredClassParentModule(this.registerClass);
48
50
  this.registerDependencies();
49
51
  this.registerDependenciesToAlias();
50
52
  }
@@ -72,12 +74,17 @@ class Module {
72
74
  const entities = this.config[entityType];
73
75
  if (entities && entities.length > 0) {
74
76
  const registeredEntities = entities
75
- .filter((target) => (0, shared_utils_1.isClass)(target) &&
76
- this.types.includes(this.metadata.determineType(target)))
77
+ .filter((target) => {
78
+ return ((0, shared_utils_1.isClass)(target) &&
79
+ this.types.includes(this.metadata.determineType(target)));
80
+ })
77
81
  .map((target) => {
78
82
  this.groupDependenciesForAlias(target);
79
83
  const targetName = (0, shared_utils_1.unCapitalize)(target.name);
80
- return { [targetName]: this.injector.getInjector(target) };
84
+ return {
85
+ [target.name]: this.injector.getInjector(target),
86
+ [targetName]: (0, awilix_1.aliasTo)(target.name),
87
+ };
81
88
  });
82
89
  Object.assign(this.registerClass, ...registeredEntities);
83
90
  }
@@ -116,6 +123,17 @@ class Module {
116
123
  }
117
124
  });
118
125
  }
126
+ registerAllProviders() {
127
+ const listProviders = this.injector.getAllProvider();
128
+ listProviders.forEach((value, key) => {
129
+ const providerInject = this.injector.getInjectProvider({
130
+ key,
131
+ value,
132
+ });
133
+ this.registerClass[key] = providerInject;
134
+ this.registerClass[(0, shared_utils_1.snakeToCamel)(key)] = (0, awilix_1.aliasTo)(key);
135
+ });
136
+ }
119
137
  /**
120
138
  * Devuelve las importaciones del módulo.
121
139
  * @returns {any[] | undefined} - Importaciones del módulo.
@@ -0,0 +1,4 @@
1
+ export interface IFactoryOptions {
2
+ activeLoggerSystem?: boolean;
3
+ activeLoggerUser?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./factory.interface";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./classModule.mock"), exports);
4
+ tslib_1.__exportStar(require("./factory.interface"), exports);
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@zanobijs/core",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Zanobi - modern, small, powerful node.js lambda framework (@core)",
5
5
  "keywords": [],
6
6
  "author": "John Edison Cortes Rivera [Devdroide] <johne.aplicativos@gmail.com>",
7
7
  "license": "ZanobiJS Usage License \n\n Review the LICENSE file.\n\n Revise el archivo de LICENCIA.",
8
- "main": "index.js",
9
8
  "typings": "index.d.ts",
10
9
  "repository": {
11
10
  "type": "git",
@@ -24,11 +23,11 @@
24
23
  },
25
24
  "homepage": "https://github.com/devdroide/ZanobiJS#readme",
26
25
  "dependencies": {
27
- "awilix": "^9.0.0",
26
+ "awilix": "10.0.2",
28
27
  "reflect-metadata": "^0.1.13"
29
28
  },
30
29
  "peerDependencies": {
31
30
  "@zanobijs/common": "*"
32
31
  },
33
- "gitHead": "ad80511a5c3d7151aa4e722435df24a616bc1504"
32
+ "gitHead": "fd630539d6115c6aa87037f5839011c9e6e42384"
34
33
  }
@@ -8,7 +8,7 @@
8
8
  "@zanobijs/common/*": ["../common/*"]
9
9
  }
10
10
  },
11
- "exclude": ["node_modules", "dist", "test/**/*", "*.spec.ts"],
11
+ "exclude": ["node_modules", "dist", "__test__/**/*", "*.spec.ts"],
12
12
  "references": [
13
13
  {
14
14
  "path": "../common/tsconfig.build.json"
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chai_1 = require("chai");
4
- // import { Module } from "@zanobijs/common";
5
- const index_1 = require("../index");
6
- const classModule_mock_1 = require("./mocks/classModule.mock");
7
- describe("Core - factory", () => {
8
- const factory = new index_1.Factory(classModule_mock_1.ModuleTestAll);
9
- describe("Create Factory App", () => {
10
- it("should respond error to create factory by error @Module", () => {
11
- class ModuleWithoutDecorator {
12
- }
13
- try {
14
- new index_1.Factory(ModuleWithoutDecorator);
15
- }
16
- catch (error) {
17
- (0, chai_1.expect)(error.message).to.be.equal("The class must have an annotation @Module()");
18
- }
19
- });
20
- it("should respond create factory", () => {
21
- const app = factory.create();
22
- (0, chai_1.expect)(app).to.be.instanceOf(index_1.Factory);
23
- });
24
- });
25
- describe("Get Entities", () => {
26
- it("should respond apiKey to controller the app", () => {
27
- const app = factory.create();
28
- const controllerWithDepen2 = app.get("controllerWithDepen2");
29
- (0, chai_1.expect)(controllerWithDepen2.getApiKey()).to.be.equal("isApiKey_qwerty12345");
30
- });
31
- });
32
- // it("", () => {});
33
- });
@@ -1,37 +0,0 @@
1
- import { expect } from "chai";
2
- // import { Module } from "@zanobijs/common";
3
- import { Factory } from "../index";
4
- import { ModuleTestAll } from "./mocks/classModule.mock";
5
- import { ControllerWithDepen2 } from "./mocks/classWithDependeciesInject.mock";
6
-
7
- describe("Core - factory", () => {
8
- const factory = new Factory(ModuleTestAll);
9
- describe("Create Factory App", () => {
10
- it("should respond error to create factory by error @Module", () => {
11
- class ModuleWithoutDecorator {}
12
- try {
13
- new Factory(ModuleWithoutDecorator);
14
- } catch (error) {
15
- expect(error.message).to.be.equal(
16
- "The class must have an annotation @Module()",
17
- );
18
- }
19
- });
20
- it("should respond create factory", () => {
21
- const app = factory.create();
22
- expect(app).to.be.instanceOf(Factory);
23
- });
24
- });
25
- describe("Get Entities", () => {
26
- it("should respond apiKey to controller the app", () => {
27
- const app = factory.create();
28
- const controllerWithDepen2 = app.get<ControllerWithDepen2>(
29
- "controllerWithDepen2",
30
- );
31
- expect(controllerWithDepen2.getApiKey()).to.be.equal(
32
- "isApiKey_qwerty12345",
33
- );
34
- });
35
- });
36
- // it("", () => {});
37
- });
@@ -1 +0,0 @@
1
- export {};