@divine-lab/request 1.1.0 → 1.1.1

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.
@@ -101,7 +101,7 @@ async function globalErrorHandler(error, _request, reply) {
101
101
  if (error instanceof APIError_1.APIError)
102
102
  return errorResponse(reply, error.error, { title: error.title, detail: error.detail, type: error.type, data: error.data, status: error.status });
103
103
  if (error.statusCode && error.statusCode === 429)
104
- return errorResponse(reply, "TOO_MANY_REQUESTS", { title: "Too Many Requests", detail: "You have sent too many requests in a given amount of time. Please try again later.", data: error.message.match(/\d+\s+\w+/)?.[0], status: 429 });
104
+ return errorResponse(reply, "TOO_MANY_REQUESTS", { title: "Too Many Requests", detail: "You have sent too many requests in a given amount of time. Please try again later.", data: `Retry in ${error.message.match(/\d+\s+\w+/)?.[0]}`, status: 429 });
105
105
  if (error.validation) {
106
106
  const data = [];
107
107
  for (const err of error.validation)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divine-lab/request",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Simple utility for standardizing request and response objects.",
5
5
  "author": {
6
6
  "name": "Ishpreet Singh",
package/readme.md CHANGED
@@ -113,6 +113,11 @@ Additionally if a `400 Bad request` is made, then this handler should handle it
113
113
  Supports API response logging via <a>`@divine-lab/logger`</a>.
114
114
  Enable by setting ENV Variable `DIVINE_LAB_REQUEST_API_LOG` to `true`.
115
115
 
116
+ #### Updates:
117
+
118
+ - 1.1.0: added rate limit error response in backend errors and handling it in global error handler (when using `@fastify/rate-limit`)
119
+ - 1.1.1: fixed data response for the rate-limit in global error handler for fastify.
120
+
116
121
  #### Contact:
117
122
 
118
123
  - mail: <a href="mailto:ishpreet@appshala.com">ishpreet@appshala.com<a>