@athenna/http 5.31.0 → 5.33.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/http",
3
- "version": "5.31.0",
3
+ "version": "5.33.0",
4
4
  "description": "The Athenna Http server. Built on top of fastify.",
5
5
  "license": "MIT",
6
6
  "author": "João Lenon <lenon@athenna.io>",
@@ -74,40 +74,40 @@
74
74
  "#tests": "./tests/index.js"
75
75
  },
76
76
  "devDependencies": {
77
- "@athenna/artisan": "^5.6.0",
78
- "@athenna/common": "^5.7.0",
79
- "@athenna/config": "^5.3.0",
80
- "@athenna/ioc": "^5.1.0",
81
- "@athenna/logger": "^5.3.0",
82
- "@athenna/test": "^5.3.0",
77
+ "@athenna/artisan": "^5.7.0",
78
+ "@athenna/common": "^5.14.0",
79
+ "@athenna/config": "^5.4.0",
80
+ "@athenna/ioc": "^5.2.0",
81
+ "@athenna/logger": "^5.7.0",
82
+ "@athenna/test": "^5.5.0",
83
83
  "@athenna/tsconfig": "^5.0.0",
84
84
  "@athenna/view": "^5.3.0",
85
85
  "@athenna/vite": "^5.13.0",
86
- "@fastify/cors": "^10.0.2",
86
+ "@fastify/cors": "^10.1.0",
87
87
  "@fastify/helmet": "^13.0.1",
88
88
  "@fastify/multipart": "^9.0.3",
89
- "@fastify/rate-limit": "^10.2.2",
90
- "@fastify/static": "^8.0.4",
91
- "@fastify/swagger": "^9.4.2",
92
- "@fastify/swagger-ui": "^5.2.1",
93
- "@typescript-eslint/eslint-plugin": "^8.21.0",
94
- "@typescript-eslint/parser": "^8.21.0",
89
+ "@fastify/rate-limit": "^10.3.0",
90
+ "@fastify/static": "^8.2.0",
91
+ "@fastify/swagger": "^9.5.1",
92
+ "@fastify/swagger-ui": "^5.2.3",
93
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
94
+ "@typescript-eslint/parser": "^8.38.0",
95
95
  "autocannon": "^7.15.0",
96
96
  "commitizen": "^4.3.1",
97
97
  "cz-conventional-changelog": "^3.3.0",
98
98
  "eslint": "^8.57.1",
99
- "eslint-config-prettier": "^8.10.0",
99
+ "eslint-config-prettier": "^8.10.2",
100
100
  "eslint-config-standard": "^17.1.0",
101
- "eslint-plugin-import": "^2.31.0",
101
+ "eslint-plugin-import": "^2.32.0",
102
102
  "eslint-plugin-n": "^15.7.0",
103
- "eslint-plugin-prettier": "^4.2.1",
103
+ "eslint-plugin-prettier": "^4.2.5",
104
104
  "eslint-plugin-promise": "^6.6.0",
105
105
  "foreground-child": "^2.0.0",
106
106
  "husky": "^3.1.0",
107
107
  "lint-staged": "^12.5.0",
108
- "ora": "^8.1.1",
108
+ "ora": "^8.2.0",
109
109
  "prettier": "^2.8.8",
110
- "vite": "^6.0.11",
110
+ "vite": "^6.3.5",
111
111
  "vite-plugin-restart": "^0.4.2"
112
112
  },
113
113
  "c8": {
@@ -61,17 +61,17 @@ export class RouteListCommand extends BaseCommand {
61
61
  * Resolve the http routes file.
62
62
  */
63
63
  async resolveRoute() {
64
- const path = Config.get('rc.commands.route:list.route', Path.routes(`http.${Path.ext()}`));
64
+ const path = Config.get('rc.http.route', Path.routes(`http.${Path.ext()}`));
65
65
  await Module.resolve(path, this.getParentURL());
66
66
  }
67
67
  /**
68
68
  * Get the http kernel module from RC file or resolve the default one.
69
69
  */
70
70
  async getHttpKernel() {
71
- if (!Config.exists('rc.commands.route:list.kernel')) {
71
+ if (!Config.exists('rc.http.kernel')) {
72
72
  return HttpKernel;
73
73
  }
74
- return Module.resolve(Config.get('rc.commands.route:list.kernel'), this.getParentURL());
74
+ return Module.resolve(Config.get('rc.http.kernel'), this.getParentURL());
75
75
  }
76
76
  /**
77
77
  * Get the parent URL of the project.
@@ -56,21 +56,11 @@ export class HttpExceptionHandler {
56
56
  if (!Is.Exception(error)) {
57
57
  error = error.toAthennaException();
58
58
  }
59
- const isUsingJsonFormatter = Config.is('logging.channels.exception.formatter', 'json');
60
- if (isUsingJsonFormatter) {
61
- Log.channelOrVanilla('exception').error({
62
- name: error.name,
63
- code: error.code,
64
- status: error.status,
65
- message: error.message,
66
- help: error.help,
67
- cause: error.cause,
68
- details: error.details,
69
- stack: error.stack
70
- });
59
+ if (Config.is('http.logger.prettifyException', true)) {
60
+ Log.channelOrVanilla('exception').error(await error.prettify());
71
61
  return;
72
62
  }
73
- Log.channelOrVanilla('exception').error(await error.prettify());
63
+ Log.channelOrVanilla('exception').error(error);
74
64
  }
75
65
  /**
76
66
  * Return a boolean indicating if the error can be logged or not.
@@ -31,11 +31,11 @@ export declare class HttpKernel {
31
31
  /**
32
32
  * Register the cls-rtracer plugin in the Http server.
33
33
  */
34
- registerRTracer(trace?: boolean): Promise<void>;
34
+ registerRTracer(): Promise<void>;
35
35
  /**
36
36
  * Register the @athenna/vite plugin in the Http server.
37
37
  */
38
- registerVite(trace?: boolean): Promise<void>;
38
+ registerVite(): Promise<void>;
39
39
  /**
40
40
  * Register the @fastify/multipart plugin in the Http server.
41
41
  */
@@ -111,13 +111,9 @@ export class HttpKernel {
111
111
  /**
112
112
  * Register the cls-rtracer plugin in the Http server.
113
113
  */
114
- async registerRTracer(trace) {
114
+ async registerRTracer() {
115
115
  const rTracerPlugin = await Module.safeImport('cls-rtracer');
116
- if (trace === false) {
117
- debug('Not able to register rTracer plugin. Set the trace option as true in your http server options.');
118
- return;
119
- }
120
- if (trace === undefined && Config.is('http.rTracer.enabled', false)) {
116
+ if (Config.is('http.rTracer.enabled', false)) {
121
117
  debug('Not able to register rTracer plugin. Set the http.rTracer.enabled configuration as true.');
122
118
  return;
123
119
  }
@@ -131,13 +127,9 @@ export class HttpKernel {
131
127
  /**
132
128
  * Register the @athenna/vite plugin in the Http server.
133
129
  */
134
- async registerVite(trace) {
130
+ async registerVite() {
135
131
  const vitePlugin = await Module.safeImport('@athenna/vite/plugins/fastify');
136
- if (trace === false) {
137
- debug('Not able to register vite plugin. Set the trace option as true in your http server options.');
138
- return;
139
- }
140
- if (trace === undefined && Config.is('http.vite.enabled', false)) {
132
+ if (Config.is('http.vite.enabled', false)) {
141
133
  debug('Not able to register vite plugin. Set the http.vite.enabled configuration as true.');
142
134
  return;
143
135
  }
@@ -173,10 +165,10 @@ export class HttpKernel {
173
165
  const { channel, isToLogRequest } = Config.get('http.logger');
174
166
  Server.terminate(ctx => {
175
167
  if (!isToLogRequest) {
176
- return Log.channelOrVanilla(channel).info(ctx);
168
+ return Log.channelOrVanilla(channel || 'request').info(ctx);
177
169
  }
178
170
  if (isToLogRequest(ctx)) {
179
- return Log.channelOrVanilla(channel).info(ctx);
171
+ return Log.channelOrVanilla(channel || 'request').info(ctx);
180
172
  }
181
173
  });
182
174
  }