Skip to content

Commit

Permalink
fix(core.gbapp): Self-replication on Azure
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Jun 5, 2019
1 parent 4d484d0 commit f29c8c2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"botbuilder-choices": "4.0.0-preview1.2",
"botbuilder-dialogs": "4.4.0",
"botbuilder-prompts": "4.0.0-preview1.2",
"botlib": "1.2.0",
"botlib": "^1.2.1",
"chai": "4.2.0",
"child_process": "1.0.2",
"chokidar": "3.0.0",
Expand Down Expand Up @@ -246,4 +246,4 @@
"post-merge": []
}
}
}
}
15 changes: 15 additions & 0 deletions packages/core.gbapp/services/GBCoreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import { GBLog, IGBCoreService, IGBInstallationDeployer, IGBInstance, IGBPackage } from 'botlib';
import * as fs from 'fs';
import { Sequelize } from 'sequelize-typescript';
import { GBServer } from '../../../src/app';
import { GBAdminPackage } from '../../admin.gbapp/index';
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
import { GBAnalyticsPackage } from '../../analytics.gblib';
Expand Down Expand Up @@ -261,6 +262,20 @@ STORAGE_SYNC=true
}
}

public installWebHook(isGet: boolean, url: string, callback: any) {

if (isGet) {
GBServer.globals.server.get(url, (req, res) => {
callback(req, res);
});
} else {
GBServer.globals.server.post(url, (req, res) => {
callback(req, res);
});

}
}

public async saveInstance(fullInstance: any) {
const options = { where: {} };
options.where = { botId: fullInstance.botId };
Expand Down
5 changes: 3 additions & 2 deletions packages/core.gbapp/services/GBDeployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const graph = require('@microsoft/microsoft-graph-client');
import { GBError, GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
import { AzureSearch } from 'pragmatismo-io-framework';
import { GBServer } from '../../../src/app';
import { GuaribasPackage, GuaribasInstance } from '../models/GBModel';
import { GuaribasPackage } from '../models/GBModel';
import { GBAdminService } from './../../admin.gbapp/services/GBAdminService';
import { AzureDeployerService } from './../../azuredeployer.gbapp/services/AzureDeployerService';
import { KBService } from './../../kb.gbapp/services/KBService';
Expand Down Expand Up @@ -232,7 +232,7 @@ export class GBDeployer {

switch (packageType) {
case '.gbot':
await this.deployBot(localPath, min.proxyAddress);
await this.deployBot(localPath, GBServer.globals.publicAddress);

case '.gbkb':
const service = new KBService(this.core.sequelize);
Expand Down Expand Up @@ -371,6 +371,7 @@ export class GBDeployer {
GBLog.info(`Theme (.gbtheme) assets accessible at: /themes/${filenameOnly}.`);
} else if (Path.extname(filename) === '.gbkb') {
server.use(`/kb/${filenameOnly}/subjects`, express.static(urlJoin(filename, 'subjects')));
server.use(`/kb/${filenameOnly}/images`, express.static(urlJoin(filename, 'images')));
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${filenameOnly}.`);
} else if (Path.extname(filename) === '.gbui') {
// Already Handled
Expand Down
2 changes: 1 addition & 1 deletion packages/customer-satisfaction.gbapp/services/CSService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class CSService {
instanceId: number,
questionTyped: string,
questionText: string): Promise<GuaribasQuestionAlternate> {
return GuaribasQuestionAlternate.create({
return await GuaribasQuestionAlternate.create({
questionTyped: questionTyped,
questionText: questionText
});
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const appPackages: IGBPackage[] = [];
*/
export class RootData {
public publicAddress: string;
public server: any;
}

/**
Expand All @@ -74,6 +75,7 @@ export class GBServer {
GBServer.globals = new RootData();
const port = GBConfigService.getServerPort();
const server = express();
GBServer.globals.server = server;
server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: true }));

Expand Down

0 comments on commit f29c8c2

Please sign in to comment.