fix (core.gbapp): warnings and comments handled.

This commit is contained in:
Rodrigo Rodriguez 2020-01-08 17:52:46 -03:00
parent 071f38cfc3
commit eca9099225
6 changed files with 34 additions and 48 deletions

31
boot.js
View file

@ -4,27 +4,29 @@ const Fs = require('fs');
const Path = require('path');
const { exec } = require('child_process');
// display version of Node JS being used at runtime and others runtime attributes
console.log(`process.version = ${process.version}`);
console.log(`process.env = ${process.env}`);
console.log(`process.platform = ${process.platform}`);
console.log(`process.release = ${process.release}`);
console.log(`process.argv = ${process.argv}`);
console.log(`process.env.USER = ${process.env.USER}`);
console.log(`process.env.PATH = ${process.env.PATH.split(':').join('\n')}`);
console.log(`process.env.PWD = ${process.env.PWD}`);
console.log(`process.env.HOME = ${process.env.HOME}`);
console.log(`process.debugPort = ${process.debugPort}`);
// Displays version of Node JS being used at runtime and others attributes.
console.log(`[GB Runtime] version = ${process.version}`);
console.log(`[GB Runtime] env = ${process.env}`);
console.log(`[GB Runtime] platform = ${process.platform}`);
console.log(`[GB Runtime] release = ${process.release}`);
console.log(`[GB Runtime] argv = ${process.argv}`);
console.log(`[GB Runtime] env.USER = ${process.env.USER}`);
console.log(`[GB Runtime] env.PATH = ${process.env.PATH.split(':').join('\n')}`);
console.log(`[GB Runtime] env.PWD = ${process.env.PWD}`);
console.log(`[GB Runtime] env.HOME = ${process.env.HOME}`);
console.log(`[GB Runtime] debugPort = ${process.debugPort}`);
var now = () => {
return (new Date()).toISOString().replace(/T/, ' ').replace(/\..+/, '') + ' UTC';
}
try {
// 1. define functions: run and processDist
var run = () => {
console.log(`[GB Runtime] Now starting General Bots Server...`);
const GBServer = require("./dist/src/app").GBServer
console.log(`${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
console.log(`[GB Runtime] ${now()} - Running '${GBServer.name}' on '${__dirname}' directory`);
process.env.PWD = __dirname;
GBServer.run();
}
@ -44,7 +46,8 @@ try {
}
};
// 2. start running
// Installing modules if it has not been done yet.
if (!Fs.existsSync('node_modules')) {
console.log(`${now()} - Installing modules for the first time, please wait...`);
exec('npm install', (err, stdout, stderr) => {

View file

@ -33,8 +33,8 @@
"pretest": "npm run build",
"coveralls": "npm run test && nyc report --reporter=text-lcov | coveralls",
"start": "node ./boot.js",
"reverse-proxy": "node_modules/.bin/ngrok http 4242",
"watch:build": "tsc --watch",
"watch:server": "nodemon './dist/index.js' --watch './dist'",
"posttypedoc": "shx cp .nojekyll docs/reference/.nojekyll",
"ban": "ban",
"issues": "git-issues",
@ -116,7 +116,6 @@
"git-issues": "1.3.1",
"license-checker": "25.0.1",
"nsp": "3.2.1",
"pre-commit": "^1.2.2",
"prettier-standard": "^16.1.0",
"semantic-release": "^15.14.0",
"travis-deploy-once": "5.0.11",
@ -205,18 +204,8 @@
},
"pre-git": {
"commit-msg": "simple",
"pre-commit": [
"npm prune",
"git add packages/*.ts",
"npm run ban"
],
"pre-push": [
"echo skip npm run unused-deps",
"echo skip npm npm run secure",
"echo skip npm run license",
"echo skip npm run ban -- --all",
"echo skip run size"
],
"pre-commit": [],
"pre-push": [],
"post-commit": [],
"post-checkout": [],
"post-merge": []

View file

@ -38,7 +38,7 @@
import { GBLog, IGBCoreService, IGBInstallationDeployer, IGBInstance, IGBPackage } from 'botlib';
import * as fs from 'fs';
import { Sequelize } from 'sequelize-typescript';
import { Sequelize, SequelizeOptions } from 'sequelize-typescript';
import { Op, Dialect } from 'sequelize';
import { GBServer } from '../../../src/app';
import { GBAdminPackage } from '../../admin.gbapp/index';
@ -133,7 +133,11 @@ export class GBCoreService implements IGBCoreService {
const encrypt: boolean = GBConfigService.get('STORAGE_ENCRYPT') === 'true';
const acquire = parseInt(GBConfigService.get('STORAGE_ACQUIRE_TIMEOUT'));
const sequelizeOptions = {
const sequelizeOptions: SequelizeOptions = {
define: {
freezeTableName: true,
timestamps: false
},
host: host,
logging: logging as boolean,
dialect: this.dialect as Dialect,
@ -154,7 +158,7 @@ export class GBCoreService implements IGBCoreService {
this.sequelize = new Sequelize(
database,
username,
password,
password,
sequelizeOptions
);
@ -265,7 +269,7 @@ STORAGE_SYNC=true
} catch (error) {
// There are false positive from ngrok regarding to no memory, but it's just
// lack of connection.
throw new Error(`Error connecting to remote ngrok server, please check network connection. ${error.msg}`);
}
}
@ -284,7 +288,7 @@ STORAGE_SYNC=true
}
}
public async deleteInstance(botId:string) {
public async deleteInstance(botId: string) {
const options = { where: {} };
options.where = { botId: botId };
await GuaribasInstance.destroy(options);

View file

@ -3035,7 +3035,7 @@
},
"callsites": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
"resolved": "http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz",
"integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA="
},
"camel-case": {

View file

@ -335,17 +335,7 @@ class GBUIApp extends React.Component {
if (!this.state.instance) {
sideBar = '';
}
return (
<div>
{gbCss}
{sideBar}
<div className="player">{playerComponent}</div>
<div className="webchat">
</div>
</div>
);
/*
return (
<div>
{gbCss}
@ -355,7 +345,7 @@ class GBUIApp extends React.Component {
{chat}
</div>
</div>
); */
);
}
}

View file

@ -49,8 +49,8 @@ export class GBWhatsappPackage implements IGBPackage {
public loadBot(min: GBMinInstance): void {
// Only loads engine if it is defined on services.json.
if (min.instance.whatsappBotKey !== undefined) {
min.whatsAppDirectLine = new WhatsappDirectLine(
if (min.instance.whatsappBotKey !== undefined && min.instance.whatsappBotKey !== null ) {
min.whatsAppDirectLine = new WhatsappDirectLine(
min.botId,
min.instance.whatsappBotKey,
min.instance.whatsappServiceKey,