@avleon/core 0.0.38 → 0.0.39

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.
@@ -54,7 +54,7 @@ const path_1 = __importDefault(require("path"));
54
54
  const fs_1 = __importStar(require("fs"));
55
55
  const typedi_1 = require("typedi");
56
56
  const system_exception_1 = require("./exceptions/system-exception");
57
- dotenv_1.default.config({ path: path_1.default.join(process.cwd(), ".env") });
57
+ dotenv_1.default.config({ path: path_1.default.join(process.cwd(), ".env"), quiet: true });
58
58
  /**
59
59
  * @class Environment
60
60
  * @description A service class to manage access to environment variables.
@@ -60,7 +60,6 @@ let EventDispatcher = class EventDispatcher {
60
60
  for (const transport of transports) {
61
61
  if (transport === "socket") {
62
62
  const io = typedi_1.Container.get(socket_io_1.Server);
63
- //console.log('SOckert', Container.get(SocketContextService));
64
63
  const context = typedi_1.Container.get(SocketContextService);
65
64
  const socket = context.getSocket();
66
65
  if (options.broadcast && socket) {
package/dist/icore.d.ts CHANGED
@@ -208,15 +208,6 @@ export declare class AvleonApplication {
208
208
  getTestApp(buildOptions?: any): TestApplication;
209
209
  }
210
210
  export type Application = typeof AvleonApplication;
211
- export interface ITestBuilder {
212
- getTestApplication(): AvleonTestAppliction;
213
- createTestApplication(options: any): AvleonTestAppliction;
214
- }
215
- export interface IAppBuilder {
216
- registerPlugin<T extends Function, S extends {}>(plugin: T, options: S): Promise<void>;
217
- addDataSource<T extends IConfig<R>, R = ReturnType<InstanceType<Constructable<T>>["config"]>>(ConfigClass: Constructable<T>, modifyConfig?: (config: R) => R): void;
218
- build<T extends IAvleonApplication>(): T;
219
- }
220
211
  export declare class AvleonTest {
221
212
  private constructor();
222
213
  static getController<T>(controller: Constructor<T>, deps?: any[]): T;
package/dist/icore.js CHANGED
@@ -528,7 +528,6 @@ class AvleonApplication {
528
528
  const module = await Promise.resolve(`${filePath}`).then(s => __importStar(require(s)));
529
529
  for (const exported of Object.values(module)) {
530
530
  if (typeof exported === "function" && (0, container_1.isApiController)(exported)) {
531
- console.log("adding", exported.name);
532
531
  if (!this.controllers.some((con) => exported.name == con.name)) {
533
532
  this.controllers.push(exported);
534
533
  }
@@ -651,7 +650,6 @@ class AvleonApplication {
651
650
  }
652
651
  _mapFeatures() {
653
652
  const features = typedi_1.default.get("features");
654
- console.log("Features", features);
655
653
  }
656
654
  async initializeDatabase() {
657
655
  if (this.dataSourceOptions && this.dataSource) {
@@ -707,7 +705,6 @@ class AvleonApplication {
707
705
  await this.app.io.use((socket, next) => {
708
706
  const token = socket.handshake.auth.token;
709
707
  try {
710
- console.log("token", token);
711
708
  const user = { id: 1, name: "tareq" };
712
709
  socket.data.user = user; // this powers @AuthUser()
713
710
  next();
@@ -766,13 +763,31 @@ class AvleonApplication {
766
763
  };
767
764
  }
768
765
  catch (error) {
769
- console.log(error);
770
766
  throw new system_exception_1.SystemUseError("Can't get test appliction");
771
767
  }
772
768
  }
773
769
  }
774
770
  exports.AvleonApplication = AvleonApplication;
775
771
  AvleonApplication.buildOptions = {};
772
+ // Applciation Builder
773
+ // export interface ITestBuilder {
774
+ // getTestApplication(): AvleonTestAppliction;
775
+ // createTestApplication(options: any): AvleonTestAppliction;
776
+ // }
777
+ // export interface IAppBuilder {
778
+ // registerPlugin<T extends Function, S extends {}>(
779
+ // plugin: T,
780
+ // options: S,
781
+ // ): Promise<void>;
782
+ // addDataSource<
783
+ // T extends IConfig<R>,
784
+ // R = ReturnType<InstanceType<Constructable<T>>["config"]>,
785
+ // >(
786
+ // ConfigClass: Constructable<T>,
787
+ // modifyConfig?: (config: R) => R,
788
+ // ): void;
789
+ // build<T extends IAvleonApplication>(): T;
790
+ // }
776
791
  class AvleonTest {
777
792
  constructor() {
778
793
  process.env.NODE_ENV = "test";
@@ -6,51 +6,20 @@
6
6
  */
7
7
  import { OpenApiOptions } from "./openapi";
8
8
  export type RouteMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "ALL";
9
- /**
10
- * Options for defining a route's method and metadata.
11
- */
12
9
  export type RouteMethodOptions = {
13
- /**
14
- * HTTP method for the route (e.g., GET, POST, PUT, DELETE).
15
- */
16
10
  method?: RouteMethods;
17
- /**
18
- * The path or endpoint for the route (e.g., "/users/:id").
19
- */
20
11
  path?: string;
21
- /**
22
- * OpenAPI metadata for the route, including summary and description.
23
- */
24
12
  openapi?: OpenApiOptions;
25
- /**
26
- * Name of the route.
27
- *
28
- * @description If Swagger is enabled in the project, this will appear as a tag in the generated documentation.
29
- */
30
13
  name?: string;
31
14
  };
32
- export declare function createRouteDecorator(method?: RouteMethods): (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
33
- /**
34
- * @description HTTP Get method
35
- * @param {string} path
36
- */
37
- export declare function Get(path?: string): MethodDecorator;
38
- export declare function Get(path: string | RouteMethodOptions): MethodDecorator;
39
15
  /**
40
- * @description HTTP Get method
41
- * @param {string} path
42
- * @param {RouteMethodOptions} options
16
+ * Generic Route decorator factory
43
17
  */
44
- export declare function Get(path: string, options: RouteMethodOptions): MethodDecorator;
45
- export declare function Post(path?: string): MethodDecorator;
46
- export declare function Post(path: string | RouteMethodOptions): MethodDecorator;
47
- export declare function Post(path: string, options: RouteMethodOptions): MethodDecorator;
48
- export declare function Put(path?: string): MethodDecorator;
49
- export declare function Put(path: string | RouteMethodOptions): MethodDecorator;
50
- export declare function Put(path: string, options: RouteMethodOptions): MethodDecorator;
51
- export declare function Delete(path?: string): MethodDecorator;
52
- export declare function Delete(path: string | RouteMethodOptions): MethodDecorator;
53
- export declare function Delete(path: string, options: RouteMethodOptions): MethodDecorator;
54
- export declare const Patch: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
55
- export declare const Options: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
56
- export declare const All: (pathOrOptions: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
18
+ export declare function Route(method: RouteMethods, pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions): MethodDecorator;
19
+ export declare const Get: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
20
+ export declare const Post: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
21
+ export declare const Put: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
22
+ export declare const Delete: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
23
+ export declare const Patch: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
24
+ export declare const Options: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
25
+ export declare const All: (pathOrOptions?: string | RouteMethodOptions, maybeOptions?: RouteMethodOptions) => MethodDecorator;
@@ -6,78 +6,44 @@
6
6
  * @url https://github.com/xtareq
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.All = exports.Options = exports.Patch = void 0;
10
- exports.createRouteDecorator = createRouteDecorator;
9
+ exports.All = exports.Options = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
10
+ exports.Route = Route;
11
+ const container_1 = require("./container");
12
+ /**
13
+ * Generic Route decorator factory
14
+ */
15
+ function Route(method, pathOrOptions, maybeOptions) {
16
+ return function (target, propertyKey, descriptor) {
17
+ let path = "/";
18
+ let options = {};
19
+ if (typeof pathOrOptions === "string") {
20
+ path = pathOrOptions;
21
+ options = maybeOptions || {};
22
+ }
23
+ else if (typeof pathOrOptions === "object") {
24
+ options = pathOrOptions;
25
+ path = options.name || "/";
26
+ }
27
+ // Define metadata
28
+ Reflect.defineMetadata("route:path", path, target, propertyKey);
29
+ Reflect.defineMetadata("route:method", method, target, propertyKey);
30
+ Reflect.defineMetadata(container_1.ROUTE_META_KEY, { ...options, method, path, controller: target.constructor.name }, target, propertyKey);
31
+ if (options) {
32
+ Reflect.defineMetadata("route:options", options, target, propertyKey);
33
+ }
34
+ };
35
+ }
36
+ const Get = (pathOrOptions, maybeOptions) => Route("GET", pathOrOptions, maybeOptions);
11
37
  exports.Get = Get;
38
+ const Post = (pathOrOptions, maybeOptions) => Route("POST", pathOrOptions, maybeOptions);
12
39
  exports.Post = Post;
40
+ const Put = (pathOrOptions, maybeOptions) => Route("PUT", pathOrOptions, maybeOptions);
13
41
  exports.Put = Put;
42
+ const Delete = (pathOrOptions, maybeOptions) => Route("DELETE", pathOrOptions, maybeOptions);
14
43
  exports.Delete = Delete;
15
- const container_1 = require("./container");
16
- const schema = {
17
- tags: ["hello"],
18
- };
19
- // Overloads
20
- // Implementation
21
- function createRouteDecorator(method = "GET") {
22
- return function (pathOrOptions, maybeOptions) {
23
- return function (target, propertyKey, descriptor) {
24
- let path = "/";
25
- let options = {};
26
- if (typeof pathOrOptions === "string") {
27
- path = pathOrOptions;
28
- options = maybeOptions || {};
29
- }
30
- else if (typeof pathOrOptions === "object") {
31
- options = pathOrOptions;
32
- path = options.name || "/";
33
- }
34
- // Define metadata
35
- Reflect.defineMetadata("route:path", path, target, propertyKey);
36
- Reflect.defineMetadata("route:method", method || "GET", target, propertyKey);
37
- Reflect.getMetadata(container_1.CONTROLLER_META_KEY, target.constructor);
38
- Reflect.defineMetadata(container_1.ROUTE_META_KEY, { ...options, method, path, controller: target.constructor.name }, target, propertyKey);
39
- if (options) {
40
- Reflect.defineMetadata("route:options", options, target, propertyKey);
41
- }
42
- };
43
- };
44
- }
45
- function Get(path, options) {
46
- const parsedPath = !path && !options ? "/" : path;
47
- if (options) {
48
- return createRouteDecorator("GET")(parsedPath, options);
49
- }
50
- else {
51
- return createRouteDecorator("GET")(parsedPath);
52
- }
53
- }
54
- function Post(path, options) {
55
- const parsedPath = !path && !options ? "/" : path;
56
- if (options) {
57
- return createRouteDecorator("POST")(parsedPath, options);
58
- }
59
- else {
60
- return createRouteDecorator("POST")(parsedPath);
61
- }
62
- }
63
- function Put(path, options) {
64
- const parsedPath = !path && !options ? "/" : path;
65
- if (options) {
66
- return createRouteDecorator("PUT")(parsedPath, options);
67
- }
68
- else {
69
- return createRouteDecorator("PUT")(parsedPath);
70
- }
71
- }
72
- function Delete(path, options) {
73
- const parsedPath = !path && !options ? "/" : path;
74
- if (options) {
75
- return createRouteDecorator("DELETE")(parsedPath, options);
76
- }
77
- else {
78
- return createRouteDecorator("DELETE")(parsedPath);
79
- }
80
- }
81
- exports.Patch = createRouteDecorator("PATCH");
82
- exports.Options = createRouteDecorator("OPTIONS");
83
- exports.All = createRouteDecorator("ALL");
44
+ const Patch = (pathOrOptions, maybeOptions) => Route("PATCH", pathOrOptions, maybeOptions);
45
+ exports.Patch = Patch;
46
+ const Options = (pathOrOptions, maybeOptions) => Route("OPTIONS", pathOrOptions, maybeOptions);
47
+ exports.Options = Options;
48
+ const All = (pathOrOptions, maybeOptions) => Route("ALL", pathOrOptions, maybeOptions);
49
+ exports.All = All;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avleon/core",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "keywords": [
@@ -11,64 +11,69 @@
11
11
  ],
12
12
  "author": "Tareq Hossain",
13
13
  "license": "ISC",
14
- "devDependencies": {
15
- "@types/jest": "^29.5.14",
16
- "@types/node": "^20.17.25",
17
- "@types/pg": "^8.15.2",
18
- "@typescript-eslint/eslint-plugin": "^8.32.0",
19
- "@typescript-eslint/parser": "^8.32.0",
20
- "class-transformer": "^0.5.1",
21
- "class-validator": "^0.14.1",
22
- "eslint": "^9.26.0",
23
- "eslint-config-prettier": "^10.1.5",
24
- "husky": "^8.0.0",
25
- "ioredis": "^5.6.1",
26
- "jest": "^29.7.0",
27
- "knex": "^3.1.0",
28
- "lint-staged": "^16.0.0",
29
- "mssql": "^11.0.1",
30
- "mysql2": "^3.14.1",
31
- "nodemon": "^3.1.7",
32
- "pg": "^8.16.0",
33
- "prettier": "^3.5.3",
34
- "sharp": "^0.33.5",
35
- "sqlite": "^5.1.1",
36
- "sqlite3": "^5.1.7",
37
- "ts-jest": "^29.2.5",
38
- "ts-node": "^10.9.2",
39
- "tsc-watch": "^6.2.1",
40
- "typeorm": "^0.3.20",
41
- "typescript": "^5.7.2"
14
+ "description": "avleon core",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/avleonjs/avleon-core"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "directories": {
23
+ "test": "."
42
24
  },
43
25
  "dependencies": {
44
- "@fastify/cors": "^11.0.0",
45
- "@fastify/multipart": "^9.0.3",
46
- "@fastify/static": "^8.1.1",
47
- "@fastify/swagger": "^9.4.0",
48
- "@fastify/swagger-ui": "^5.1.0",
49
- "@fastify/view": "^11.0.0",
50
- "@types/mssql": "^9.1.7",
51
- "bcryptjs": "^3.0.2",
52
- "cross-env": "^7.0.3",
53
- "dotenv": "^16.4.7",
54
- "fastify": "^5.1.0",
55
- "fastify-socket.io": "^5.1.0",
56
- "highlight.js": "^11.9.0",
57
- "pino": "^9.6.0",
58
- "pino-pretty": "^13.0.0",
26
+ "class-transformer": "^0.5.1",
27
+ "class-validator": "^0.14.2",
28
+ "fastify": "^5.6.0",
29
+ "pino": "^9.10.0",
59
30
  "reflect-metadata": "^0.2.2",
60
- "rimraf": "^6.0.1",
61
- "socket.io": "^4.8.1",
62
31
  "typedi": "^0.10.0"
63
32
  },
64
33
  "peerDependencies": {
34
+ "@fastify/cors": "*",
35
+ "@fastify/multipart": "*",
36
+ "@fastify/static": "*",
37
+ "@fastify/swagger": "*",
38
+ "@fastify/swagger-ui": "*",
39
+ "@fastify/view": "*",
65
40
  "@scalar/fastify-api-reference": "*",
41
+ "bcryptjs": "3.0.2",
42
+ "dotenv": "*",
43
+ "fastify-socket.io": "*",
44
+ "highlight.js": "*",
66
45
  "ioredis": "*",
46
+ "knex": "*",
47
+ "mssql": "*",
48
+ "mysql2": "*",
49
+ "pg": "*",
67
50
  "sharp": "*",
68
- "typeorm": "*",
69
- "knex": "*"
51
+ "socket.io": "*",
52
+ "sqlite3": "*",
53
+ "typeorm": "*"
70
54
  },
71
55
  "peerDependenciesMeta": {
56
+ "bcryptjs": {
57
+ "optional": true
58
+ },
59
+ "@fastify/cors": {
60
+ "optional": true
61
+ },
62
+ "@fastify/multipart": {
63
+ "optional": true
64
+ },
65
+ "@fastify/static": {
66
+ "optional": true
67
+ },
68
+ "@fastify/swagger": {
69
+ "optional": true
70
+ },
71
+ "@fastify/swagger-ui": {
72
+ "optional": true
73
+ },
74
+ "@fastify/view": {
75
+ "optional": true
76
+ },
72
77
  "@scalar/fastify-api-reference": {
73
78
  "optional": true
74
79
  },
@@ -83,8 +88,49 @@
83
88
  },
84
89
  "knex": {
85
90
  "optional": true
91
+ },
92
+ "mssql": {
93
+ "optional": true
94
+ },
95
+ "mysql2": {
96
+ "optional": true
97
+ },
98
+ "pg": {
99
+ "optional": true
100
+ },
101
+ "sqlite3": {
102
+ "optional": true
103
+ },
104
+ "fastify-socket.io": {
105
+ "optional": true
106
+ },
107
+ "socket.io": {
108
+ "optional": true
109
+ },
110
+ "dotenv": {
111
+ "optional": true
112
+ },
113
+ "highlight.js": {
114
+ "optional": true
86
115
  }
87
116
  },
117
+ "devDependencies": {
118
+ "@types/bcryptjs": "^3.0.0",
119
+ "@types/jest": "^29.5.14",
120
+ "@types/node": "^20.19.17",
121
+ "@typescript-eslint/eslint-plugin": "^8.44.0",
122
+ "@typescript-eslint/parser": "^8.44.0",
123
+ "eslint": "^9.36.0",
124
+ "eslint-config-prettier": "^10.1.8",
125
+ "husky": "^8.0.3",
126
+ "jest": "^29.7.0",
127
+ "lint-staged": "^16.1.6",
128
+ "prettier": "^3.6.2",
129
+ "rimraf": "^6.0.1",
130
+ "ts-jest": "^29.4.4",
131
+ "tsc-watch": "^6.3.1",
132
+ "typescript": "^5.7.2"
133
+ },
88
134
  "lint-staged": {
89
135
  "*.{js,ts,json,md}": "pnpm format",
90
136
  "*.{js,ts}": [
@@ -92,20 +138,6 @@
92
138
  "cross-env CI=true jest --bail --findRelatedTests --passWithNoTests --config=jest.config.js"
93
139
  ]
94
140
  },
95
- "optionalDependencies": {
96
- "typeorm": "*"
97
- },
98
- "directories": {
99
- "test": "."
100
- },
101
- "description": "avleon core",
102
- "repository": {
103
- "type": "git",
104
- "url": "git+https://github.com/avleonjs/avleon-core"
105
- },
106
- "files": [
107
- "dist"
108
- ],
109
141
  "scripts": {
110
142
  "build": "npm run clean && tsc",
111
143
  "clean": "rimraf dist",