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