fix(core): update

This commit is contained in:
2020-09-30 00:13:14 +00:00
parent 82f4413064
commit 18fad25b8c
50 changed files with 19 additions and 1826 deletions

View File

@ -1,4 +1,5 @@
import * as plugins from './smartuniverse.plugins';
import * as pluginsTyped from './smartuniverse.pluginstyped';
import { Handler, Route, Server } from '@pushrocks/smartexpress';
import { UniverseCache, UniverseChannel, UniverseMessage } from './';
@ -11,7 +12,7 @@ import { logger } from './smartuniverse.logging';
export interface ISmartUniverseConstructorOptions {
messageExpiryInMilliseconds: number;
externalServer?: plugins.smartexpress.Server;
externalServer?: pluginsTyped.smartexpress.Server;
}
/**
@ -27,7 +28,7 @@ export class Universe {
/**
* the smartexpress server used
*/
private smartexpressServer: plugins.smartexpress.Server;
private smartexpressServer: pluginsTyped.smartexpress.Server;
/**
* the smartsocket used
@ -79,23 +80,16 @@ export class Universe {
* initiates a server
*/
public async start(portArg: number) {
// lets create the base smartexpress server
if (!this.options.externalServer) {
this.smartexpressServer = new plugins.smartexpress.Server({
cors: true,
defaultAnswer: async () => {
return `smartuniverse server ${this.getUniverseVersion()}`;
},
forceSsl: false,
port: portArg,
});
} else {
console.log('Universe is using externally supplied server');
this.smartexpressServer = this.options.externalServer;
}
// add websocket upgrade
this.smartsocket = new plugins.smartsocket.Smartsocket({});
this.smartsocket = new plugins.smartsocket.Smartsocket({
port: portArg
});
// lets create the base smartexpress server
if (this.options.externalServer) {
console.log('Universe is using externally supplied server');
this.smartsocket.setExternalServer('smartexpress' ,this.options.externalServer);
}
// add a role for the clients
const ClientRole = new plugins.smartsocket.SocketRole({
@ -159,13 +153,7 @@ export class Universe {
this.smartsocket.addSocketFunction(socketFunctionSubscription);
this.smartsocket.addSocketFunction(socketFunctionProcessMessage);
// start the server
if (!this.options.externalServer) {
await this.smartexpressServer.start();
}
// add smartsocket to the running smartexpress app
await this.smartsocket.setExternalServer('smartexpress', this.smartexpressServer);
await this.smartsocket.start();
logger.log('success', 'started universe');
}
@ -175,8 +163,5 @@ export class Universe {
*/
public async stopServer() {
await this.smartsocket.stop();
if (!this.options.externalServer) {
await this.smartexpressServer.stop();
}
}
}

View File

@ -12,7 +12,6 @@ export { typedrequestInterfaces };
import * as lik from '@pushrocks/lik';
import * as smarthash from '@pushrocks/smarthash';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartexpress from '@pushrocks/smartexpress';
import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartpromise from '@pushrocks/smartpromise';
@ -26,7 +25,6 @@ export {
lik,
smarthash,
smartdelay,
smartexpress,
smartfile,
smartlog,
smartpromise,

View File

@ -0,0 +1,5 @@
import type * as smartexpress from '@pushrocks/smartexpress';
export {
smartexpress
};