summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--routes.js6
-rw-r--r--utils.js4
2 files changed, 5 insertions, 5 deletions
diff --git a/routes.js b/routes.js
index 207a022..ec333ec 100644
--- a/routes.js
+++ b/routes.js
@@ -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);
diff --git a/utils.js b/utils.js
index 695063f..1fc17c6 100644
--- a/utils.js
+++ b/utils.js
@@ -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);