Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
enforced string double quotation
Browse files Browse the repository at this point in the history
  • Loading branch information
xurzua committed Dec 14, 2017
1 parent bfcf4c2 commit 0b11543
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 76 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const server = require('./core/server');
const server = require("./core/server");
10 changes: 5 additions & 5 deletions common/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
// IMPORTS
//--------------------------------------------------------------------------------------

const fs = require('fs');
const Logger = require('bunyan');
const config = require('../common/settings');
const fs = require("fs");
const Logger = require("bunyan");
const config = require("../common/settings");

//--------------------------------------------------------------------------------------
// GLOBAL VARIABLES
//--------------------------------------------------------------------------------------

const settings = config.getSettings();
const LOGGER_SETTINGS = settings.logger.parameters;
const dir = './log';
const dir = "./log";

//--------------------------------------------------------------------------------------
// LOGGER FUNCTIONS
Expand All @@ -28,7 +28,7 @@ const isLogDirExist = (dir) => {
isLogDirExist(dir);

const log = Logger.createLogger({
name: 'SOE',
name: "SOE",
streams: [{
stream: process.stdout,
level: LOGGER_SETTINGS.logLevel
Expand Down
20 changes: 10 additions & 10 deletions common/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// IMPORTS
//--------------------------------------------------------------------------------------

const fs = require('fs');
const fs = require("fs");
var settings = null;

//--------------------------------------------------------------------------------------
Expand All @@ -15,13 +15,13 @@ const getSettings = () => {
}
}

throw ('There is no configuration file in the current directory. Check if the settings.json file exist!');
throw ("There is no configuration file in the current directory. Check if the settings.json file exist!");
};

const isSettingsFileExist = () => {
try {
fs.statSync('settings.json').isFile();
settings = require('../settings.json');
fs.statSync("settings.json").isFile();
settings = require("../settings.json");
return true;
} catch (err) {
return false;
Expand All @@ -36,11 +36,11 @@ const isSettingsFileEmpty = () => {
Object.values(parameters).forEach(key => {
if (isParameterObject(key)) {
if (isParameterObjectEmpty(key)) {
throw ('Check you settings.json file, there is a missing, null or undefined parameter in your configuration file');
throw ("Check you settings.json file, there is a missing, null or undefined parameter in your configuration file");
}
} else {
if (isParameterEmpty(key)) {
throw ('Check you settings.json file, there is a missing, null or undefined parameter in your configuration file');
throw ("Check you settings.json file, there is a missing, null or undefined parameter in your configuration file");
}
}
});
Expand All @@ -50,15 +50,15 @@ const isSettingsFileEmpty = () => {
};

const isParameterObject = (obj) => {
if (typeof obj === 'object') {
if (typeof obj === "object") {
return true;
}
return false;
};

const isParameterObjectEmpty = (obj) => {
Object.values(obj).forEach(key => {
if (key === null || key === undefined || key === '') {
if (key === null || key === undefined || key === "") {
return true;
}
});
Expand All @@ -69,7 +69,7 @@ const isParameters = (obj) => {

let found = null;
Object.values(obj).forEach(key => {
if (key.hasOwnProperty('parameters')) {
if (key.hasOwnProperty("parameters")) {
found = true;
} else {
found = false;
Expand All @@ -81,7 +81,7 @@ const isParameters = (obj) => {

const isParameterEmpty = (key) => {

if (key === null || key === undefined || key === '') {
if (key === null || key === undefined || key === "") {
return true;
}
return false;
Expand Down
48 changes: 24 additions & 24 deletions core/conversation.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//--------------------------------------------------------------------------------------
// IMPORTS
//--------------------------------------------------------------------------------------
const ConversationV1 = require('watson-developer-cloud/conversation/v1');
const server = require('restify');
const custom = require('../custom/customResponses');
const logger = require('../common/logger');
const config = require('../common/settings');
const ConversationV1 = require("watson-developer-cloud/conversation/v1");
const server = require("restify");
const custom = require("../custom/customResponses");
const logger = require("../common/logger");
const config = require("../common/settings");

//--------------------------------------------------------------------------------------
// GLOBAL VARIABLES
Expand Down Expand Up @@ -52,8 +52,8 @@ const getConversationResponse = (res, response) => {
if (isConversationResponseTransfer(res)) {
response.send(custom.customHangUp(getConversationResponseParameters(res)));
} else {
log.warn('\n[OUT] WatsonConversation response is not a "vgwActTransfer" falling back to original response: --->\n');
log.warn('\n[OUT] Sending Conversation response to VoiceGateway: --->\n\n', res, '\n');
log.warn("\n[OUT] WatsonConversation response is not a \"vgwActTransfer\" falling back to original response: --->\n");
log.warn("\n[OUT] Sending Conversation response to VoiceGateway: --->\n\n", res, "\n");
response.send(200, res);
}

Expand All @@ -67,7 +67,7 @@ const getConversationResponseParameters = (res) => {
if (isConversationResponseAction(res)) {
if (isConversationResponseTransfer(res)) {
let params = res.output.vgwAction.parameters;
log.warn('\n[OUT] Transfer parameters: --->\n\n', params, '\n');
log.warn("\n[OUT] Transfer parameters: --->\n\n", params, "\n");
return params;
}
}
Expand All @@ -77,9 +77,9 @@ const getConversationResponseParameters = (res) => {
let seq = res.output.vgwActionSequence;

for (let i = 0; i < seq.length; i++) {
if (seq[i].command === 'vgwActTransfer') {
if (seq[i].command === "vgwActTransfer") {
params = seq[i].parameters;
log.warn('\n[OUT] Transfer parameters: --->\n\n', params, '\n');
log.warn("\n[OUT] Transfer parameters: --->\n\n", params, "\n");
break;
}
}
Expand All @@ -97,12 +97,12 @@ var setConversationMessage = (workspaceID, message, response) => {
password: getConversationCredentials(workspaceID).password,
version_date: ConversationV1.VERSION_DATE_2017_05_26,
headers: {
'X-Watson-Learning-Opt-Out': true
"X-Watson-Learning-Opt-Out": true
},

});

log.warn('\n[OUT] Sending VoiceGateway message to Conversation: --->\n\n', message, '\n');
log.warn("\n[OUT] Sending VoiceGateway message to Conversation: --->\n\n", message, "\n");

conversation.message({
intents: message.intents,
Expand All @@ -115,10 +115,10 @@ var setConversationMessage = (workspaceID, message, response) => {
}, (err, res) => {

if (err) {
log.error('\n[OUT] Error sending out message to Conversation: --->\n\n', err, '\n');
log.error("\n[OUT] Error sending out message to Conversation: --->\n\n", err, "\n");
response.send(500, err);
} else {
log.warn('\n[IN] Conversation Response: <---\n\n', res, '\n');
log.warn("\n[IN] Conversation Response: <---\n\n", res, "\n");
getConversationResponse(res, response);
}

Expand All @@ -127,17 +127,17 @@ var setConversationMessage = (workspaceID, message, response) => {

const isConversationResponseAction = (res) => {

if ('vgwAction' in res.output) {
log.warn('\n[IN] Conversation response is an "vgwAction": <---\n');
if ("vgwAction" in res.output) {
log.warn("\n[IN] Conversation response is an \"vgwAction\": <---\n");
return true;
}
return false;
};

const isConversationResponseSequence = (res) => {

if ('vgwActionSequence' in res.output) {
log.warn('\n[IN] Conversation response is an "vgwActionSequence": <---\n');
if ("vgwActionSequence" in res.output) {
log.warn("\n[IN] Conversation response is an \"vgwActionSequence\": <---\n");
return true;
}
return false;
Expand All @@ -147,8 +147,8 @@ const isConversationResponseSequence = (res) => {
const isConversationResponseTransfer = (res) => {

if (isConversationResponseAction(res)) {
if (res.output.vgwAction.command === 'vgwActTransfer') {
log.warn('\n[IN] Conversation response is an "vgwActTransfer": <---\n');
if (res.output.vgwAction.command === "vgwActTransfer") {
log.warn("\n[IN] Conversation response is an \"vgwActTransfer\": <---\n");
return true;
}
}
Expand All @@ -159,9 +159,9 @@ const isConversationResponseTransfer = (res) => {
let found = false;

for (let i = 0; i < seq.length; i++) {
if (seq[i].command === 'vgwActTransfer') {
if (seq[i].command === "vgwActTransfer") {
found = true;
log.warn('\n[IN] Conversation response is an "vgwActTransfer": <---\n');
log.warn("\n[IN] Conversation response is an \"vgwActTransfer\": <---\n");
break;
}
}
Expand All @@ -174,8 +174,8 @@ const isConversationResponseTransfer = (res) => {

const isConversationResponseHangUp = (res) => {

if (res.input.text === 'vgwHangUp') {
log.warn('\n[OUT] Conversation sent a ' + res.input.text + ' request --->\n');
if (res.input.text === "vgwHangUp") {
log.warn("\n[OUT] Conversation sent a " + res.input.text + " request --->\n");
return true;
}
return false;
Expand Down
12 changes: 6 additions & 6 deletions core/reporting.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//--------------------------------------------------------------------------------------
// IMPORTS
//--------------------------------------------------------------------------------------
const PouchDB = require('pouchdb');
const logger = require('../common/logger');
const config = require('../common/settings');
const PouchDB = require("pouchdb");
const logger = require("../common/logger");
const config = require("../common/settings");

//--------------------------------------------------------------------------------------
// GLOBAL VARIABLES
Expand All @@ -18,7 +18,7 @@ const setDBLogMessage = (message) => {
const db = setDBInstanceConnection();

db.post(message).then((res) => {
log.info('\n[SOE] VoiceGateway reporting event logged successfully : \n\n', res, '\n\n');
log.info("\n[SOE] VoiceGateway reporting event logged successfully : \n\n", res, "\n\n");
}).catch((error) => {
log.error(error);
});
Expand All @@ -35,7 +35,7 @@ var isDBReportingEnabled = () => {

const isDBInstanceProtocolSecure = () => {

if (COUCHDB_SETTINGS.protocol === 'https') {
if (COUCHDB_SETTINGS.protocol === "https") {
return true;
}

Expand All @@ -44,7 +44,7 @@ const isDBInstanceProtocolSecure = () => {

const setDBInstanceConnection = () => {

let url = COUCHDB_SETTINGS.protocol + '://' + COUCHDB_SETTINGS.host + ':' + COUCHDB_SETTINGS.port + '/' + COUCHDB_SETTINGS.database;
let url = COUCHDB_SETTINGS.protocol + "://" + COUCHDB_SETTINGS.host + ":" + COUCHDB_SETTINGS.port + "/" + COUCHDB_SETTINGS.database;

if (isDBInstanceProtocolSecure()) {

Expand Down
36 changes: 18 additions & 18 deletions core/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// IMPORTS
//--------------------------------------------------------------------------------------

const restify = require('restify');
const cluster = require('cluster');
const conversation = require('./conversation');
const report = require('./reporting');
const logger = require('../common/logger');
const config = require('../common/settings');
const restify = require("restify");
const cluster = require("cluster");
const conversation = require("./conversation");
const report = require("./reporting");
const logger = require("../common/logger");
const config = require("../common/settings");

//--------------------------------------------------------------------------------------
// GLOBAL VARIABLES
Expand All @@ -22,8 +22,8 @@ const log = logger.log;
//--------------------------------------------------------------------------------------

const server = restify.createServer({
name: 'Service Orchestration Engine',
version: '2.2.0',
name: "Service Orchestration Engine",
version: "2.2.0",
certificate: null,
key: null,
formatters: null,
Expand All @@ -43,17 +43,17 @@ server.use(restify.plugins.jsonBodyParser({
// SERVER ENDPOINTS
//--------------------------------------------------------------------------------------

server.post('/v1/workspaces/:workspaceID/message', function (request, response) {
server.post("/v1/workspaces/:workspaceID/message", function (request, response) {

let message = request.body;
let workspaceID = request.params.workspaceID;

log.warn('\n[IN] VoiceGateway Request: <---\n\n', message, '\n');
log.warn("\n[IN] VoiceGateway Request: <---\n\n", message, "\n");
conversation.setConversationMessage(workspaceID, message, response);

});

server.post('/reporting', function (request, response) {
server.post("/reporting", function (request, response) {

if (report.isDBReportingEnabled()) {
return new Promise((resolve, reject) => {
Expand All @@ -64,7 +64,7 @@ server.post('/reporting', function (request, response) {
report.setDBLogMessage(message);
resolve();
} catch (error) {
reject(log.error('\n[SOE] There was an error trying to log the incoming event : \n\n', error, '\n\n'));
reject(log.error("\n[SOE] There was an error trying to log the incoming event : \n\n", error, "\n\n"));
}

});
Expand All @@ -80,15 +80,15 @@ server.post('/reporting', function (request, response) {

server.listen(SOE_SETTINGS.port, () => {

log.debug('[SOE] ' + server.name + ' - Version 2.2.0 (dev)');
log.debug('[SOE] Configuration file: \'settings.json\' parsed sucessfully.');
log.debug("[SOE] " + server.name + " - Version 2.2.0 (dev)");
log.debug("[SOE] Configuration file: 'settings.json' parsed sucessfully.");

if (report.isDBReportingEnabled()) {
log.debug('[SOE] Voice Gateway event reporting is enabled at /reporting.');
log.debug("[SOE] Voice Gateway event reporting is enabled at /reporting.");
} else {
log.debug('[SOE] Voice Gateway event reporting is disabled.');
log.debug("[SOE] Voice Gateway event reporting is disabled.");
}

log.debug('[SOE] Server Startup is completed.');
log.debug('[SOE] Server is handling connections at %s.', server.url);
log.debug("[SOE] Server Startup is completed.");
log.debug("[SOE] Server is handling connections at %s.", server.url);
});
Loading

0 comments on commit 0b11543

Please sign in to comment.