diff --git a/index.js b/index.js index 703fe07..7c64baf 100644 --- a/index.js +++ b/index.js @@ -60,8 +60,11 @@ const testHandler = (req, res) => { // Abort if user is blocked if (blockList.indexOf(req.params.user) !== -1) { ErrorHandler.log(`Request blocked for user ${req.params.user}`) + + const template = require(__dirname + '/templates/blocklist.status.js') + const blockListTemplate = template(req) - return res.status(429).send() + return res.status(blockListTemplate.statusCode).send(blockListTemplate.body) } const speedtracker = new SpeedTracker({ diff --git a/templates/blocklist.status.js b/templates/blocklist.status.js new file mode 100644 index 0000000..d124f7d --- /dev/null +++ b/templates/blocklist.status.js @@ -0,0 +1,57 @@ +const utils = require(__dirname + '/../lib/utils') + +const blocklist = (req) => { + const body = ` + + + + + 403 Forbidden! + + + +
+
+

ERROR 403 - Forbidden!

+
+
+

The following error occurrred:

+

Requests for user ${req.params.user} are blocked.

+
+

If you believe this is an error or would like to dispute this block then contact: abuse@speedtracker.org

+
+
+ + + ` + + return { + body, + statusCode: 403 + } +} + +module.exports = blocklist