fix(core.gbapp): Clean-up of system code
This commit is contained in:
		
							parent
							
								
									27dcdfcaa1
								
							
						
					
					
						commit
						9311943998
					
				
					 6 changed files with 19 additions and 22 deletions
				
			
		
							
								
								
									
										2
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "botserver",
 | 
			
		||||
  "version": "1.7.2",
 | 
			
		||||
  "version": "1.7.3",
 | 
			
		||||
  "lockfileVersion": 1,
 | 
			
		||||
  "requires": true,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,10 +38,10 @@
 | 
			
		|||
 | 
			
		||||
import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
 | 
			
		||||
import { Sequelize } from 'sequelize-typescript';
 | 
			
		||||
import { SwitchBotDialog } from './dialogs/SwitchBot';
 | 
			
		||||
import { WelcomeDialog } from './dialogs/WelcomeDialog';
 | 
			
		||||
import { WhoAmIDialog } from './dialogs/WhoAmIDialog';
 | 
			
		||||
import { GuaribasChannel, GuaribasException, GuaribasInstance, GuaribasPackage } from './models/GBModel';
 | 
			
		||||
import { SwitchBotDialog } from './dialogs/SwitchBot';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Package for core.gbapp.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ export const Messages = {
 | 
			
		|||
    good_night: 'boa noite',
 | 
			
		||||
    hi: (msg) => `Oi, ${msg}.`,
 | 
			
		||||
    very_sorry_about_error: `Lamento, ocorreu um erro que já foi registrado para ser tratado.`,
 | 
			
		||||
    global_quit: /^(sair|Sair)/i, 
 | 
			
		||||
    global_quit: /^(sair|Sair)/i,
 | 
			
		||||
    canceled: 'Cancelado, avise como posso ser útil novamente.'
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										0
									
								
								packages/default.gbapp.gbignore/.gitkeep
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								packages/default.gbapp.gbignore/.gitkeep
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -46,7 +46,6 @@ import { WhatsappDirectLine } from './services/WhatsappDirectLine';
 | 
			
		|||
export class GBWhatsappPackage implements IGBPackage {
 | 
			
		||||
  public sysPackages: IGBPackage[];
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public loadBot(min: GBMinInstance): void {
 | 
			
		||||
    // Only loads engine if it is defined on services.json.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +60,6 @@ export class GBWhatsappPackage implements IGBPackage {
 | 
			
		|||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  public getDialogs(min: GBMinInstance) {
 | 
			
		||||
    GBLog.verbose(`getDialogs called.`);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										33
									
								
								src/app.ts
									
										
									
									
									
								
							
							
						
						
									
										33
									
								
								src/app.ts
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -39,10 +39,10 @@
 | 
			
		|||
const express = require('express');
 | 
			
		||||
const bodyParser = require('body-parser');
 | 
			
		||||
import * as fs from 'fs';
 | 
			
		||||
var mkdirp = require('mkdirp');
 | 
			
		||||
var Path = require('path');
 | 
			
		||||
let mkdirp = require('mkdirp');
 | 
			
		||||
let Path = require('path');
 | 
			
		||||
 | 
			
		||||
import { GBLog, IGBCoreService, IGBInstance, IGBPackage, GBMinInstance } from 'botlib';
 | 
			
		||||
import { GBLog, GBMinInstance, IGBCoreService, IGBInstance, IGBPackage } from 'botlib';
 | 
			
		||||
import { GBAdminService } from '../packages/admin.gbapp/services/GBAdminService';
 | 
			
		||||
import { AzureDeployerService } from '../packages/azuredeployer.gbapp/services/AzureDeployerService';
 | 
			
		||||
import { GBConfigService } from '../packages/core.gbapp/services/GBConfigService';
 | 
			
		||||
| 
						 | 
				
			
			@ -56,14 +56,14 @@ import { GBMinService } from '../packages/core.gbapp/services/GBMinService';
 | 
			
		|||
 * Global shared server data;
 | 
			
		||||
 */
 | 
			
		||||
export class RootData {
 | 
			
		||||
  public publicAddress: string;
 | 
			
		||||
  public server: any;
 | 
			
		||||
  public sysPackages: any[];
 | 
			
		||||
  public appPackages: any[];
 | 
			
		||||
  minService: GBMinService;
 | 
			
		||||
  bootInstance: IGBInstance;
 | 
			
		||||
  public minInstances: any[];
 | 
			
		||||
  minBoot: GBMinInstance;
 | 
			
		||||
  public publicAddress: string; // URI for BotServer
 | 
			
		||||
  public server: any; // Express reference
 | 
			
		||||
  public sysPackages: any[]; // Loaded system package list
 | 
			
		||||
  public appPackages: any[]; // Loaded .gbapp package list
 | 
			
		||||
  public minService: GBMinService;  // Minimalist service core
 | 
			
		||||
  public bootInstance: IGBInstance; // General Bot Interface Instance
 | 
			
		||||
  public minInstances: any[]; //
 | 
			
		||||
  public minBoot: GBMinInstance;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -93,10 +93,10 @@ export class GBServer {
 | 
			
		|||
 | 
			
		||||
    // Creates working directory.
 | 
			
		||||
 | 
			
		||||
    const workDir = Path.join(process.env.PWD, 'work'); 
 | 
			
		||||
    if (!fs.existsSync(workDir)){
 | 
			
		||||
    const workDir = Path.join(process.env.PWD, 'work');
 | 
			
		||||
    if (!fs.existsSync(workDir)) {
 | 
			
		||||
      mkdirp.sync(workDir);
 | 
			
		||||
    } 
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    server.listen(port, () => {
 | 
			
		||||
      (async () => {
 | 
			
		||||
| 
						 | 
				
			
			@ -116,8 +116,7 @@ export class GBServer {
 | 
			
		|||
            const proxy = GBConfigService.get('REVERSE_PROXY');
 | 
			
		||||
            if (proxy !== undefined) {
 | 
			
		||||
              GBServer.globals.publicAddress = proxy;
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
            } else {
 | 
			
		||||
              // Ensure that local development proxy is setup.
 | 
			
		||||
 | 
			
		||||
              GBLog.info(`Establishing a development local proxy (ngrok)...`);
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +162,7 @@ export class GBServer {
 | 
			
		|||
          const fullInstance = Object.assign(packageInstance, GBServer.globals.bootInstance);
 | 
			
		||||
          await core.saveInstance(fullInstance);
 | 
			
		||||
          let instances: IGBInstance[] = await core.loadAllInstances(core, azureDeployer,
 | 
			
		||||
            GBServer.globals.publicAddress);
 | 
			
		||||
                                                                     GBServer.globals.publicAddress);
 | 
			
		||||
          instances = await core.ensureInstances(instances, GBServer.globals.bootInstance, core);
 | 
			
		||||
          if (GBServer.globals.bootInstance !== undefined) {
 | 
			
		||||
            GBServer.globals.bootInstance = instances[0];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue