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 +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +2 -2
package/dist/index.d.ts
CHANGED
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
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
|
}
|