@avleon/core 0.0.28 → 0.0.29

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 (42) hide show
  1. package/dist/application.js +1 -1
  2. package/dist/cache.d.ts +1 -1
  3. package/dist/cache.js +2 -2
  4. package/dist/collection.d.ts +25 -32
  5. package/dist/collection.js +50 -6
  6. package/dist/collection.test.d.ts +1 -0
  7. package/dist/collection.test.js +59 -0
  8. package/dist/config.d.ts +2 -0
  9. package/dist/config.js +30 -5
  10. package/dist/config.test.d.ts +1 -0
  11. package/dist/config.test.js +40 -0
  12. package/dist/controller.js +2 -2
  13. package/dist/environment-variables.js +42 -5
  14. package/dist/event-dispatcher.d.ts +23 -0
  15. package/dist/event-dispatcher.js +102 -0
  16. package/dist/event-subscriber.d.ts +15 -0
  17. package/dist/event-subscriber.js +96 -0
  18. package/dist/exceptions/http-exceptions.js +1 -1
  19. package/dist/exceptions/index.d.ts +1 -1
  20. package/dist/exceptions/system-exception.js +3 -1
  21. package/dist/file-storage.js +1 -1
  22. package/dist/helpers.js +1 -1
  23. package/dist/icore.d.ts +5 -0
  24. package/dist/icore.js +53 -18
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.js +6 -1
  27. package/dist/utils/index.d.ts +2 -2
  28. package/dist/utils/optional-require.js +2 -2
  29. package/dist/validation.d.ts +1 -1
  30. package/dist/websocket.d.ts +7 -0
  31. package/dist/websocket.js +20 -0
  32. package/dist/websocket.test.d.ts +0 -0
  33. package/dist/websocket.test.js +1 -0
  34. package/package.json +3 -1
  35. package/src/config.test.ts +2 -2
  36. package/src/config.ts +2 -2
  37. package/src/event-dispatcher.ts +100 -0
  38. package/src/event-subscriber.ts +79 -0
  39. package/src/icore.ts +1106 -1060
  40. package/src/index.ts +3 -1
  41. package/src/middleware.ts +6 -4
  42. package/src/websocket.ts +47 -0
package/src/index.ts CHANGED
@@ -24,7 +24,9 @@ export * from "./utils/hash";
24
24
  export * from "./multipart";
25
25
  export * from "./file-storage";
26
26
  export * from "./logger";
27
+ export * from "./event-dispatcher";
28
+ export { Subscribe, Private } from "./event-subscriber";
27
29
 
28
30
  export const GetSchema = sw.generateSwaggerSchema;
29
31
 
30
- export { default as Container } from "./container";
32
+ export { default as AvleonContainer } from "./container";
package/src/middleware.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "./exceptions";
13
13
  import Container, { AUTHORIZATION_META_KEY } from "./container";
14
14
 
15
- export abstract class AppMiddleware {
15
+ export abstract class AvleonMiddleware {
16
16
  abstract invoke(
17
17
  req: IRequest,
18
18
  res?: IResponse,
@@ -37,7 +37,9 @@ interface AuthorizeClass {
37
37
  authorize(req: IRequest, options?: any): AuthReturnTypes;
38
38
  }
39
39
 
40
- export function Authorize(target: { new (...args: any[]): AuthorizeClass }) {
40
+ export function AppAuthorization(target: {
41
+ new (...args: any[]): AuthorizeClass;
42
+ }) {
41
43
  if (typeof target.prototype.authorize !== "function") {
42
44
  throw new Error(
43
45
  `Class "${target.name}" must implement an "authorize" method.`,
@@ -74,7 +76,7 @@ export function Authorized(
74
76
  };
75
77
  }
76
78
 
77
- export function Middleware(target: Constructor<AppMiddleware>) {
79
+ export function AppMiddleware(target: Constructor<AvleonMiddleware>) {
78
80
  if (typeof target.prototype.invoke !== "function") {
79
81
  throw new Error(
80
82
  `Class "${target.name}" must implement an "invoke" method.`,
@@ -85,7 +87,7 @@ export function Middleware(target: Constructor<AppMiddleware>) {
85
87
  }
86
88
 
87
89
  export function UseMiddleware<
88
- T extends AppMiddleware | (new (...args: any[]) => AppMiddleware),
90
+ T extends AvleonMiddleware | (new (...args: any[]) => AvleonMiddleware),
89
91
  >(options: T | T[]): MethodDecorator & ClassDecorator {
90
92
  return function (
91
93
  target: Object | Function,
@@ -0,0 +1,47 @@
1
+ import { PathLike } from "node:fs";
2
+ import { Server } from "socket.io";
3
+ import { Service } from "typedi";
4
+
5
+
6
+ type FileAdapter = {
7
+ type: "file",
8
+ url?: PathLike
9
+ }
10
+
11
+ type RedisAdapter = {
12
+ type: "redis",
13
+ url?: string,
14
+ username?: string,
15
+ password?: string
16
+ }
17
+
18
+ type AdapterType = FileAdapter | RedisAdapter;
19
+
20
+
21
+ interface BrodcastAble {
22
+ channel: string;
23
+ broadstTo: () => void;
24
+ }
25
+
26
+
27
+
28
+ @Service()
29
+ export class AvleonSocketIo {
30
+
31
+ private io?: Server;
32
+
33
+ sendToAll() { }
34
+
35
+ sendOnly() { }
36
+
37
+
38
+ sendRoom() { }
39
+
40
+ receive(channel: string) { }
41
+
42
+ }
43
+
44
+
45
+
46
+
47
+