powr-sdk-api 1.3.4 → 1.4.0
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/middleware/request.js +15 -0
- package/package.json +2 -2
|
@@ -141,6 +141,21 @@ const requestHandler = (req, res, next) => {
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
// Add 404 handler to response object if not already present
|
|
145
|
+
if (!res.notFound) {
|
|
146
|
+
res.notFound = () => {
|
|
147
|
+
// Log the 404 error
|
|
148
|
+
logger.warn(`Route not found: ${req.method} ${req.path}`, {
|
|
149
|
+
requestId: req.requestId,
|
|
150
|
+
ip: req.ip,
|
|
151
|
+
userAgent: req.headers['user-agent']
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Return a consistent JSON response
|
|
155
|
+
return res.error('The requested resource was not found', 404, `${req.method} ${req.path}`);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
144
159
|
// Continue to the next middleware
|
|
145
160
|
next();
|
|
146
161
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powr-sdk-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Shared API core library for PowrStack projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@aws-sdk/client-s3": "^3.787.0",
|
|
40
40
|
"express": "^4.18.2",
|
|
41
|
-
"jsonwebtoken": "^9.0.2",
|
|
41
|
+
"jsonwebtoken": "^9.0.2",
|
|
42
42
|
"swagger-jsdoc": "^6.2.8",
|
|
43
43
|
"swagger-ui-express": "^5.0.0",
|
|
44
44
|
"winston": "^3.17.0"
|