@athenna/http 3.1.1 → 3.1.2

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.
@@ -100,7 +100,7 @@ export declare class Request {
100
100
  */
101
101
  get port(): number;
102
102
  /**
103
- * Get the server version.
103
+ * Get the http version.
104
104
  */
105
105
  get version(): string;
106
106
  /**
@@ -134,10 +134,10 @@ export class Request {
134
134
  return this.getAddressInfo().port;
135
135
  }
136
136
  /**
137
- * Get the server version.
137
+ * Get the http version.
138
138
  */
139
139
  get version() {
140
- return this.request.server.version;
140
+ return this.request.raw.httpVersion;
141
141
  }
142
142
  /**
143
143
  * Get a value from the request params or the default value.
@@ -18,6 +18,10 @@ export declare class Response {
18
18
  * Verify if the response has been already sent.
19
19
  */
20
20
  get sent(): boolean;
21
+ /**
22
+ * Get the response body sent in response.
23
+ */
24
+ get body(): any | any[];
21
25
  /**
22
26
  * Get the status code sent in response.
23
27
  */
@@ -20,6 +20,12 @@ export class Response {
20
20
  get sent() {
21
21
  return this.response.sent;
22
22
  }
23
+ /**
24
+ * Get the response body sent in response.
25
+ */
26
+ get body() {
27
+ return this.response.body;
28
+ }
23
29
  /**
24
30
  * Get the status code sent in response.
25
31
  */
@@ -43,6 +49,7 @@ export class Response {
43
49
  */
44
50
  async send(data) {
45
51
  await this.response.send(data);
52
+ this.response.body = data;
46
53
  return this;
47
54
  }
48
55
  /**
@@ -60,6 +60,7 @@ export class FastifyHandler {
60
60
  if (Is.Object(payload)) {
61
61
  payload = JSON.stringify(payload);
62
62
  }
63
+ res.body = payload;
63
64
  return payload;
64
65
  };
65
66
  }
@@ -77,7 +78,7 @@ export class FastifyHandler {
77
78
  params: req.params,
78
79
  queries: req.query,
79
80
  data: req.data,
80
- body: req.body,
81
+ body: res.body || req.body,
81
82
  headers: res.getHeaders(),
82
83
  status: res.statusCode,
83
84
  responseTime: res.getResponseTime(),
@@ -96,7 +97,7 @@ export class FastifyHandler {
96
97
  request,
97
98
  response,
98
99
  data: req.data,
99
- body: req.body,
100
+ body: res.body || req.body,
100
101
  params: req.params,
101
102
  queries: req.query,
102
103
  headers: req.headers,
package/build/index.d.ts CHANGED
@@ -10,6 +10,9 @@ declare module 'fastify' {
10
10
  interface FastifyRequest {
11
11
  data: any;
12
12
  }
13
+ interface FastifyReply {
14
+ body: any | any[];
15
+ }
13
16
  interface FastifySchema {
14
17
  hide?: boolean;
15
18
  deprecated?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/http",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
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>",
@@ -63,12 +63,13 @@
63
63
  "fastify": "^4.13.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@athenna/artisan": "^3.0.0",
67
- "@athenna/common": "^3.0.0",
68
- "@athenna/config": "^3.0.0",
69
- "@athenna/ioc": "^3.0.0",
70
- "@athenna/logger": "^3.0.0",
71
- "@athenna/view": "^3.0.0",
66
+ "@athenna/artisan": "^3.1.9",
67
+ "@athenna/common": "^3.3.1",
68
+ "@athenna/config": "^3.2.0",
69
+ "@athenna/ioc": "^3.1.5",
70
+ "@athenna/logger": "^3.1.5",
71
+ "@athenna/test": "^3.1.1",
72
+ "@athenna/view": "^3.0.3",
72
73
  "@fastify/cors": "^8.1.1",
73
74
  "@fastify/helmet": "^10.0.2",
74
75
  "@fastify/rate-limit": "^7.5.0",