-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: If route.isAllowed throws, return 403 instead of 500
- Loading branch information
Showing
3 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const debug = require("debug")("Blocks:CustomRoute") | ||
|
||
module.exports = { | ||
method: "GET", | ||
path: "/allow-throws", | ||
|
||
/** | ||
* Permission checking, if allowed: | ||
* -> continue to action | ||
* -> otherwise return 403 | ||
* | ||
* @param {Object} plugins Plugins | ||
* @param {Object} req Node request | ||
* | ||
* @return {boolean} | ||
*/ | ||
isAllowed: () => () => { | ||
throw new Error("trololo") | ||
}, | ||
|
||
/** | ||
* After schema validation and permission checking, do route logic | ||
* | ||
* @param {Object} plugins Plugins | ||
* @param {Object} req Node request | ||
* | ||
* @return {mixed} | ||
*/ | ||
action: () => () => ({ | ||
ping: "pong", | ||
}), | ||
} |