response-standardizer 1.3.1 → 1.3.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.
package/dist/index.d.ts CHANGED
@@ -35,5 +35,5 @@ export declare class ServiceException implements ServiceResponse {
35
35
  }
36
36
  export declare class ServiceResponseSuccess implements ServiceResponse {
37
37
  entity: any;
38
- constructor(entity: any);
38
+ constructor(entity?: any);
39
39
  }
package/dist/index.js CHANGED
@@ -198,7 +198,7 @@ const response = (req, res, response, handler = (eq, res, data = null) => { }) =
198
198
  }
199
199
  return exports.RestResponse.exceptionError(req, res, response.message);
200
200
  }
201
- return handler(req, res, response);
201
+ return handler(req, res, response.entity);
202
202
  };
203
203
  exports.response = response;
204
204
  const handleServiceException = (message, err) => {
@@ -239,7 +239,7 @@ class ServiceException {
239
239
  }
240
240
  exports.ServiceException = ServiceException;
241
241
  class ServiceResponseSuccess {
242
- constructor(entity) {
242
+ constructor(entity = null) {
243
243
  this.entity = entity;
244
244
  }
245
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "response-standardizer",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Express middleware to standardize API responses",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -247,7 +247,7 @@ export const response = (
247
247
  }
248
248
  return RestResponse.exceptionError(req, res, response.message)
249
249
  }
250
- return handler(req, res, response)
250
+ return handler(req, res, (response as ServiceResponseSuccess).entity)
251
251
  }
252
252
  export const handleServiceException = (message: string, err: any) : ServiceResponse => {
253
253
  if(err instanceof ZodError){
@@ -282,5 +282,5 @@ export class ServiceException implements ServiceResponse {
282
282
  constructor(public code: number, public message: string, public errors?: ErrorFields) {}
283
283
  }
284
284
  export class ServiceResponseSuccess implements ServiceResponse {
285
- constructor(public entity: any) {}
285
+ constructor(public entity: any = null) {}
286
286
  }