@carecard/common-util 3.0.6 → 3.0.7

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/index.js CHANGED
@@ -1,5 +1,12 @@
1
+ const util = require( './lib/untilityFunctions' );
2
+ const error = require( './lib/appErrorHandlers' );
3
+ const resCode = require( './lib/responseStatus' );
4
+
1
5
  module.exports = {
2
- util: require( './lib/untilityFunctions' ),
3
- error: require( './lib/appErrorHandlers' ),
4
- resCode: require( './lib/responseStatus' )
6
+ util,
7
+ error,
8
+ resCode,
9
+ ...util,
10
+ ...error,
11
+ ...resCode
5
12
  }
@@ -29,6 +29,7 @@ module.exports = {
29
29
 
30
30
 
31
31
  function notFound404(req, res, next) {
32
+ console.log('404 Not Found:', req.method, req.originalUrl);
32
33
  res.status(404);
33
34
  const response = {
34
35
  error:
@@ -43,6 +44,10 @@ function notFound404(req, res, next) {
43
44
  }
44
45
 
45
46
  function appErrorHandler(err, req, res, next) {
47
+ if (res.headersSent) {
48
+ return next(err)
49
+ }
50
+
46
51
  const response =
47
52
  {
48
53
  error:
@@ -114,7 +119,7 @@ function appErrorHandler(err, req, res, next) {
114
119
  break;
115
120
 
116
121
  case "Not_Authorized":
117
- res.status(401);
122
+ res.status(403);
118
123
  res.send(response)
119
124
  break;
120
125
 
@@ -139,6 +144,7 @@ function appErrorHandler(err, req, res, next) {
139
144
  break;
140
145
 
141
146
  default:
147
+ console.error('Unhandled Error:', err);
142
148
  res.status(500);
143
149
  res.send(response)
144
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carecard/common-util",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "repository": "https://github.com/CareCard-ca/pkg-common-util",
5
5
  "description": "Common utility for MVC framework",
6
6
  "main": "index.js",