prs help, why is it dying on me

This commit is contained in:
Daniel Hübleitner
2019-07-28 15:07:34 +02:00
parent f4c26b5aa6
commit 3661e17936
8 changed files with 644 additions and 303 deletions
+18 -6
View File
@@ -3,13 +3,15 @@
import * as Logger from 'log4js'
import { Plugin, socketioRPC } from 'frontblock-generic/Plugin';
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
import { FrontblockApiConf } from "frontblock/FrontblockApiClient"
//import { FrontblockApiConf } from "frontblock/FrontblockApiClient"
import {PluginManager} from "live-plugin-manager";
type pluginEntry = {pluginPath:string, conf?:any}
type pluginEntry = {pluginName:string}
const pluginList:pluginEntry[] = [
{pluginName: 'frontblock'}
//{ pluginPath: '../../paymentmanager/static/Plugin', conf:<FrontblockApiConf>{ apiHost: 'localhost' /*/ 'api.testnet.frontblock.me' */, apiPort: 10001 } },
//{ pluginPath: '../../htmlsupplier/static/Plugin' },
{ pluginPath: 'frontblock/FrontblockApiClient', conf:<FrontblockApiConf>{ apiHost: /*/ 'localhost' */ 'api.testnet.frontblock.me' , apiPort: 10001 } }
// { pluginPath: 'frontblock/FrontblockApiClient', conf:<FrontblockApiConf>{ apiHost: /*/ 'localhost' */ 'api.testnet.frontblock.me' , apiPort: 10001 } }
]
const express = require('express')
@@ -27,6 +29,8 @@ Logger.configure({
})
const logger = Logger.getLogger("admin")
const manager = new PluginManager();
type hookRPC = { type: 'hook', generator: (socket) => Function, unhook:(uid:string)=>Promise<ErrorResponse|SuccessResponse>}
type unhookRPC = { type: 'unhook', fn: Function}
type callRPC = { type: 'call', fn: Function}
@@ -74,11 +78,19 @@ export class FrontblockAdmin{
private async loadPlugins(){
this.plugins = []
pluginList.forEach(async (entry:pluginEntry) => {
const clazz = await import(entry.pluginPath)
let obj = new clazz.default(entry.conf)
this.plugins.push(obj)
logger.info("installing plugin " + entry.pluginName)
const info = await manager.installFromNpm(entry.pluginName);
logger.info("loading plugin " + info)
const clazz = manager.require(entry.pluginName);
//let obj = new clazz.default(entry.conf)
//this.plugins.push(obj)
})
}
private initApis(socket){