@bool-ts/core 1.6.2 → 1.6.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.
@@ -1,17 +1,17 @@
1
- export { Body, Params, Param, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
1
+ export { Body, Context, Param, Params, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
2
2
  export { Controller } from "./controller";
3
+ export { Dispatcher } from "./dispatcher";
3
4
  export { Guard } from "./guard";
5
+ export { Delete, Get, Options, Patch, Post, Put } from "./http";
4
6
  export { Inject } from "./inject";
5
7
  export { Injectable } from "./injectable";
6
8
  export { Middleware } from "./middleware";
7
9
  export { Module } from "./module";
8
- export { Get, Post, Put, Patch, Delete, Options } from "./http";
9
10
  export { ZodSchema } from "./zodSchema";
10
- export { Dispatcher } from "./dispatcher";
11
+ export type { TArgumentsMetadata } from "./arguments";
11
12
  export type { TControllerMetadata } from "./controller";
12
- export type { TModuleMetadata, TModuleOptions } from "./module";
13
+ export type { TDispatcherMetadata } from "./dispatcher";
14
+ export type { TGuardMetadata } from "./guard";
13
15
  export type { THttpMetadata } from "./http";
14
- export type { TArgumentsMetadata } from "./arguments";
15
16
  export type { TMiddlewareMetadata } from "./middleware";
16
- export type { TGuardMetadata } from "./guard";
17
- export type { TDispatcherMetadata } from "./dispatcher";
17
+ export type { TModuleMetadata, TModuleOptions } from "./module";
@@ -1,10 +1,10 @@
1
- export { Body, Params, Param, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
1
+ export { Body, Context, Param, Params, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
2
2
  export { Controller } from "./controller";
3
+ export { Dispatcher } from "./dispatcher";
3
4
  export { Guard } from "./guard";
5
+ export { Delete, Get, Options, Patch, Post, Put } from "./http";
4
6
  export { Inject } from "./inject";
5
7
  export { Injectable } from "./injectable";
6
8
  export { Middleware } from "./middleware";
7
9
  export { Module } from "./module";
8
- export { Get, Post, Put, Patch, Delete, Options } from "./http";
9
10
  export { ZodSchema } from "./zodSchema";
10
- export { Dispatcher } from "./dispatcher";
@@ -91,7 +91,7 @@ export const BoolFactory = async (target, options) => {
91
91
  fetch: () => new Response()
92
92
  });
93
93
  }
94
- const { loaders, middlewares, guards, beforeDispatchers, controllers, afterDispatchers, prefix: modulePrefix, config: moduleConfig } = moduleMetadata;
94
+ const { loaders, middlewares, guards, beforeDispatchers, controllers, afterDispatchers, dependencies, prefix: modulePrefix, config: moduleConfig } = moduleMetadata;
95
95
  // Configuration(s)
96
96
  const { allowLogsMethods, config } = Object.freeze({
97
97
  allowLogsMethods: options?.log?.methods,
@@ -128,6 +128,8 @@ export const BoolFactory = async (target, options) => {
128
128
  Injector.set(key, value);
129
129
  }
130
130
  }
131
+ // Dependencies
132
+ !dependencies || dependencies.map((dependency) => Injector.get(dependency));
131
133
  // Middleware(s)
132
134
  const middlewareGroup = !middlewares
133
135
  ? []
@@ -1,5 +1,5 @@
1
1
  import "reflect-metadata";
2
- import { injectableKey, controllerKey, middlewareKey, guardKey, dispatcherKey, injectKey } from "../keys";
2
+ import { controllerKey, dispatcherKey, guardKey, injectableKey, injectKey, middlewareKey } from "../keys";
3
3
  export const Injector = new (class {
4
4
  _mapper = new Map();
5
5
  /**
@@ -15,7 +15,6 @@ export const Injector = new (class {
15
15
  }
16
16
  const ownMetadataKeys = Reflect.getMetadataKeys(definition);
17
17
  if (![injectableKey, controllerKey, middlewareKey, guardKey, dispatcherKey].some((value) => ownMetadataKeys.includes(value))) {
18
- console.error(definition);
19
18
  throw Error("Missing dependency declaration, please check @Injectable() used on dependency(ies).");
20
19
  }
21
20
  // Initialize dependencies injection
@@ -13,7 +13,7 @@ export declare const httpServerErrors: Readonly<{
13
13
  }>;
14
14
  export declare class HttpServerError<T extends keyof typeof httpServerErrors = keyof typeof httpServerErrors, K = any> extends Error {
15
15
  readonly httpCode: T;
16
- readonly message: typeof httpServerErrors[T] | string;
16
+ readonly message: (typeof httpServerErrors)[T] | string;
17
17
  readonly data: K;
18
18
  constructor({ httpCode, data, message }: {
19
19
  httpCode: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bool-ts/core",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,18 +1,18 @@
1
- export { Body, Params, Param, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
1
+ export { Body, Context, Param, Params, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
2
2
  export { Controller } from "./controller";
3
+ export { Dispatcher } from "./dispatcher";
3
4
  export { Guard } from "./guard";
5
+ export { Delete, Get, Options, Patch, Post, Put } from "./http";
4
6
  export { Inject } from "./inject";
5
7
  export { Injectable } from "./injectable";
6
8
  export { Middleware } from "./middleware";
7
9
  export { Module } from "./module";
8
- export { Get, Post, Put, Patch, Delete, Options } from "./http";
9
10
  export { ZodSchema } from "./zodSchema";
10
- export { Dispatcher } from "./dispatcher";
11
11
 
12
+ export type { TArgumentsMetadata } from "./arguments";
12
13
  export type { TControllerMetadata } from "./controller";
13
- export type { TModuleMetadata, TModuleOptions } from "./module";
14
+ export type { TDispatcherMetadata } from "./dispatcher";
15
+ export type { TGuardMetadata } from "./guard";
14
16
  export type { THttpMetadata } from "./http";
15
- export type { TArgumentsMetadata } from "./arguments";
16
17
  export type { TMiddlewareMetadata } from "./middleware";
17
- export type { TGuardMetadata } from "./guard";
18
- export type { TDispatcherMetadata } from "./dispatcher";
18
+ export type { TModuleMetadata, TModuleOptions } from "./module";
@@ -155,6 +155,7 @@ export const BoolFactory = async (target: new (...args: any[]) => unknown, optio
155
155
  beforeDispatchers,
156
156
  controllers,
157
157
  afterDispatchers,
158
+ dependencies,
158
159
  prefix: modulePrefix,
159
160
  config: moduleConfig
160
161
  } = moduleMetadata;
@@ -200,6 +201,9 @@ export const BoolFactory = async (target: new (...args: any[]) => unknown, optio
200
201
  }
201
202
  }
202
203
 
204
+ // Dependencies
205
+ !dependencies || dependencies.map((dependency) => Injector.get(dependency));
206
+
203
207
  // Middleware(s)
204
208
  const middlewareGroup = !middlewares
205
209
  ? []
@@ -1,5 +1,5 @@
1
1
  import "reflect-metadata";
2
- import { injectableKey, controllerKey, middlewareKey, guardKey, dispatcherKey, injectKey } from "../keys";
2
+ import { controllerKey, dispatcherKey, guardKey, injectableKey, injectKey, middlewareKey } from "../keys";
3
3
 
4
4
  type TDefinition<T = any> = { new (...args: any[]): T } | string | symbol;
5
5
 
@@ -31,7 +31,6 @@ export const Injector: IInjector = new (class {
31
31
  ownMetadataKeys.includes(value)
32
32
  )
33
33
  ) {
34
- console.error(definition);
35
34
  throw Error("Missing dependency declaration, please check @Injectable() used on dependency(ies).");
36
35
  }
37
36
 
@@ -12,23 +12,12 @@ export const httpServerErrors = Object.freeze({
12
12
  511: "NETWORK_AUTHENTICATION_REQUIRED"
13
13
  });
14
14
 
15
- export class HttpServerError<
16
- T extends keyof typeof httpServerErrors = keyof typeof httpServerErrors,
17
- K = any
18
- > extends Error {
15
+ export class HttpServerError<T extends keyof typeof httpServerErrors = keyof typeof httpServerErrors, K = any> extends Error {
19
16
  public readonly httpCode: T;
20
- public readonly message: typeof httpServerErrors[T] | string;
17
+ public readonly message: (typeof httpServerErrors)[T] | string;
21
18
  public readonly data: K;
22
19
 
23
- constructor({
24
- httpCode,
25
- data,
26
- message
27
- }: {
28
- httpCode: T;
29
- data: K;
30
- message?: string;
31
- }) {
20
+ constructor({ httpCode, data, message }: { httpCode: T; data: K; message?: string }) {
32
21
  super();
33
22
 
34
23
  this.httpCode = httpCode;