diff options
| -rw-r--r-- | routes.js | 6 | ||||
| -rw-r--r-- | utils.js | 4 |
2 files changed, 5 insertions, 5 deletions
@@ -7,13 +7,13 @@ const router = express.Router(); async function createRoute(res, url, slug) { try { if (!utils.isUrlFormatted(url)) - return utils.sendBadRequestError(res, 'URL "'+url+'" is malformatted. Must be a valid URL.'); + return utils.sendBadRequestError(res, 'URL "'+url+'" is malformatted. Must be a valid URL.', 'Malformed URL'); if (!utils.isAlphaNumeric(slug)) - return utils.sendBadRequestError(res, 'Slug "'+slug+'" is malformatted. Must be alphanumeric.'); + return utils.sendBadRequestError(res, 'Slug "'+slug+'" is malformatted. Must be alphanumeric.', 'Malformed Short URL'); slug = slug.toLowerCase(); if (await Url.exists({slug: slug})) - return utils.sendBadRequestError(res, 'Slug "'+slug+'" already exists. Updates are not supported at this time.'); + return utils.sendBadRequestError(res, 'Slug "'+slug+'" already exists. Updates are not supported at this time.', 'Already Exists'); await new Url({url, slug}).save(); utils.sendSuccessfulSlugCreation(res, slug); @@ -24,8 +24,8 @@ const helperFunctions = { else res.send(JSON.stringify(statusJson)); }); }, - sendBadRequestError : function (res, errorMessage) { - res.status(400).json({status: "ERROR", statusCode: 400, errorType: "BAD REQUEST", errorMessage, uiString: "Already Exists"}); + sendBadRequestError : function (res, errorMessage, uiString) { + res.status(400).json({status: "ERROR", statusCode: 400, errorType: "BAD REQUEST", errorMessage, uiString}); }, sendInternalServerError : function (res, error) { console.error('[express] Error:', error); |
