@athenna/http 5.8.0 → 5.9.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.8.0",
3
+ "version": "5.9.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>",
@@ -75,19 +75,19 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@athenna/artisan": "^5.3.0",
78
- "@athenna/common": "^5.3.0",
78
+ "@athenna/common": "^5.4.0",
79
79
  "@athenna/config": "^5.1.0",
80
80
  "@athenna/ioc": "^5.0.0",
81
81
  "@athenna/logger": "^5.1.0",
82
82
  "@athenna/test": "^5.2.0",
83
83
  "@athenna/tsconfig": "^5.0.0",
84
84
  "@athenna/view": "^5.1.0",
85
- "@fastify/cors": "^8.5.0",
86
- "@fastify/helmet": "^11.1.1",
87
- "@fastify/rate-limit": "^8.1.1",
88
- "@fastify/static": "^7.0.4",
89
- "@fastify/swagger": "^8.15.0",
90
- "@fastify/swagger-ui": "^3.1.0",
85
+ "@fastify/cors": "^10.0.1",
86
+ "@fastify/helmet": "^13.0.0",
87
+ "@fastify/rate-limit": "^10.2.1",
88
+ "@fastify/static": "^8.0.3",
89
+ "@fastify/swagger": "^9.4.0",
90
+ "@fastify/swagger-ui": "^5.2.0",
91
91
  "@fastify/vite": "^7.0.1",
92
92
  "@typescript-eslint/eslint-plugin": "^7.18.0",
93
93
  "@typescript-eslint/parser": "^7.18.0",
@@ -216,7 +216,7 @@ export class Response {
216
216
  */
217
217
  async redirectTo(url, status) {
218
218
  if (status) {
219
- await this.response.redirect(status, url);
219
+ await this.response.redirect(url, status);
220
220
  return this;
221
221
  }
222
222
  await this.response.redirect(url);
@@ -25,9 +25,13 @@ export class HttpExceptionHandler {
25
25
  * The exception handler of all request handlers.
26
26
  */
27
27
  async handle({ error, response }) {
28
+ let code = error.code;
29
+ if (error.code === undefined) {
30
+ code = error.name || 'E_INTERNAL_SERVER';
31
+ }
28
32
  const body = {
29
33
  statusCode: Json.copy(error.statusCode) || Json.copy(error.status) || 500,
30
- code: String.toSnakeCase(`${error.code}` || error.name || 'E_INTERNAL_SERVER').toUpperCase(),
34
+ code: String.toSnakeCase(code).toUpperCase(),
31
35
  name: Json.copy(error.name),
32
36
  message: Json.copy(error.message),
33
37
  details: Json.copy(error.details),
@@ -10,7 +10,7 @@ import { ServiceProvider } from '@athenna/ioc';
10
10
  import { ServerImpl } from '#src/server/ServerImpl';
11
11
  export class HttpServerProvider extends ServiceProvider {
12
12
  register() {
13
- this.container.instance('Athenna/Core/HttpServer', new ServerImpl());
13
+ this.container.instance('Athenna/Core/HttpServer', new ServerImpl(Config.get('http.fastify')));
14
14
  }
15
15
  async shutdown() {
16
16
  const Server = this.container.use('Athenna/Core/HttpServer');
@@ -11,7 +11,7 @@ import { Options } from '@athenna/common';
11
11
  import { FastifyHandler } from '#src/handlers/FastifyHandler';
12
12
  export class ServerImpl {
13
13
  constructor(options) {
14
- this.fastify = fastify.fastify(options);
14
+ this.fastify = fastify.fastify({ ...options, exposeHeadRoutes: false });
15
15
  this.isListening = false;
16
16
  this.fastify.decorateReply('body', null);
17
17
  this.fastify.decorateRequest('data', null);