response-standardizer 1.3.0 → 1.3.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.
package/dist/index.d.ts CHANGED
@@ -23,7 +23,7 @@ export declare const error: (message: string, meta?: any) => void;
23
23
  export declare const warn: (message: string, meta?: any) => void;
24
24
  export declare const info: (message: string, meta?: any) => void;
25
25
  export declare const log: (level: "INFO" | "WARN" | "ERROR", message: string, meta?: any) => void;
26
- export declare const response: (req: Request, res: Response, response: ServiceResponse, handler?: <T>(eq: Request, res: Response, data: T) => void) => void;
26
+ export declare const response: (req: Request, res: Response, response: ServiceResponse, handler?: (eq: Request, res: Response, data?: any) => void) => void;
27
27
  export declare const handleServiceException: (message: string, err: any) => ServiceResponse;
28
28
  export interface ServiceResponse {
29
29
  }
package/dist/index.js CHANGED
@@ -179,7 +179,7 @@ const log = (level, message, meta) => {
179
179
  console.log(`${color}[${timestamp}][${location}][${level}] ${message}${metaStr}${colors.RESET}`);
180
180
  };
181
181
  exports.log = log;
182
- const response = (req, res, response, handler = (eq, res, data) => { }) => {
182
+ const response = (req, res, response, handler = (eq, res, data = null) => { }) => {
183
183
  if (response instanceof ServiceException) {
184
184
  if (response?.code === 401) {
185
185
  return exports.RestResponse.unauthorized(req, res, response?.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "response-standardizer",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
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
@@ -231,7 +231,7 @@ export const response = (
231
231
  req: Request,
232
232
  res: Response,
233
233
  response: ServiceResponse,
234
- handler = <T>(eq: Request, res: Response, data: T) => {}
234
+ handler = (eq: Request, res: Response, data: any = null) => {}
235
235
  ) => {
236
236
  if(response instanceof ServiceException){
237
237
  if(response?.code === 401){