Skip to content

Commit b57dd2a

Browse files
authored
Update package.json packages to latest version (#215)
adapt serialize-error to use a dynamic import instead of deprecated require use express.json to replace bodyParser.json (remove bodyparser)
1 parent add1cfb commit b57dd2a

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

core/nodejsActionBase/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var service = require('./src/service').getService(config);
4141
* setup a middleware layer to restrict the request body size
4242
* this middleware is called every time a request is sent to the server
4343
*/
44-
app.use(bodyParser.json({ limit: config.requestBodyLimit }));
44+
app.use(express.json({ limit: config.requestBodyLimit }));
4545

4646
// identify the target Serverless platform
4747
const platformFactory = require('./platform/platform.js');

core/nodejsActionBase/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88
},
99
"license": "Apache-2.0",
1010
"devDependencies": {
11-
"btoa": "1.1.2",
11+
"btoa": "1.2.1",
1212
"eslint": "^5.16.0",
1313
"eslint-config-standard": "^12.0.0",
1414
"eslint-plugin-import": "^2.17.2",
1515
"eslint-plugin-node": "^8.0.1",
1616
"eslint-plugin-promise": "^4.1.1",
1717
"eslint-plugin-standard": "^4.0.0",
18-
"request": "2.79.0"
18+
"request": "2.88.2"
1919
},
2020
"dependencies": {
21-
"openwhisk": "3.21.4",
22-
"body-parser": "1.18.3",
23-
"express": "4.16.4",
24-
"serialize-error": "3.0.0",
25-
"redis": "2.8.0",
26-
"uuid": "3.3.0"
21+
"openwhisk": "3.21.6",
22+
"express": "4.17.3",
23+
"serialize-error": "9.1.0",
24+
"redis": "4.0.4",
25+
"uuid": "8.3.2"
2726
}
2827
}

core/nodejsActionBase/runner.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,17 @@ class NodeActionRunner {
104104
if (!error) {
105105
resolve({error: {}});
106106
} else {
107-
const serializeError = require('serialize-error');
108-
resolve({error: serializeError(error)});
107+
// Replace unsupported require statement with
108+
// dynamically import npm serialize-error package returning a promise
109+
import('serialize-error')
110+
.then(module => {
111+
// if serialize-error is imported correctly the function resolves with a serializedError
112+
resolve({error: module.serializeError(error)});
113+
})
114+
.catch(err => {
115+
// When there is an error to serialize the error object, resolve with the error message
116+
resolve({error: err.message });
117+
});
109118
}
110119
});
111120
}

0 commit comments

Comments
 (0)