Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #431 from gibkigonzo/bugfix/disable-showing-stack
Browse files Browse the repository at this point in the history
disable showing stack for invalid requests
  • Loading branch information
Tomasz Kostuch authored Apr 10, 2020
2 parents 4bde19c + 270b520 commit f089244
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add correct paths for production build - @cewald (#407)
- Fix MSI default stock id value
- Add outputFormatter to response from cache - @gibkigonzo (#428)
- disable showing stack for invalid requests - @gibkigonzo (#431)


## [1.11.1] - 2020.03.17
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"availableCacheTags": ["P", "C", "T", "A", "product", "category", "attribute", "taxrule"],
"invalidateCacheKey": "aeSu7aip",
"invalidateCacheForwarding": false,
"invalidateCacheForwardUrl": "http://localhost:3000/invalidate?key=aeSu7aip&tag="
"invalidateCacheForwardUrl": "http://localhost:3000/invalidate?key=aeSu7aip&tag=",
"showErrorStack": false
},
"orders": {
"useServerQueue": false
Expand Down
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ app.use('/graphql', graphqlExpress(req => ({

app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));

app.use((err, req, res, next) => {
const { statusCode, message = '', stack = '' } = err;
const stackTrace = stack
.split(/\r?\n/)
.map(string => string.trim())
.filter(string => string !== '')

res.status(statusCode).json({
code: statusCode,
result: message,
...(config.get('server.showErrorStack') ? { stack: stackTrace } : {})
});
});

export default app;

0 comments on commit f089244

Please sign in to comment.