app2-api/helpers/message.helper.js
2019-04-24 23:01:54 +02:00

37 lines
1.0 KiB
JavaScript

'use strict';
////////////////////////////////////////////////////////////////////////////////
// CONSTANTS
////////////////////////////////////////////////////////////////////////////////
const TITLE_ERROR = 'error';
const TITLE_MESSAGE = 'message';
////////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
function buildGenericMessage(nameMessage, textMessage) {
const jsonMessageResult = {};
jsonMessageResult[nameMessage] = textMessage;
return jsonMessageResult;
}
////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
function buildErrorMessage(text) {
return buildGenericMessage(TITLE_ERROR, text)
}
function buildMessage(text) {
return buildGenericMessage(TITLE_MESSAGE, text)
}
module.exports = {
buildErrorMessage,
buildMessage,
//For testing
buildGenericMessage
}