Browse Source

Fix package issues

dev
David Ludwig 4 years ago
parent
commit
60eca7af43
3 changed files with 10 additions and 10 deletions
  1. +2
    -2
      packages/database/src/DatabaseService.ts
  2. +3
    -3
      packages/webserver/src/WebServerService.ts
  3. +5
    -5
      packages/websocket-server/src/WebSocketServerService.ts

+ 2
- 2
packages/database/src/DatabaseService.ts View File

@ -39,7 +39,7 @@ export class DatabaseService<M extends Microservice = Microservice> extends Inte
/**
* Boot the database service
*/
public async boot() {
public override async boot() {
let password = await secret(DB.DATABASE_PASSWORD_FILE);
let database = env("DATABASE");
this.connection = await this.connectToDatabase(
@ -56,7 +56,7 @@ export class DatabaseService<M extends Microservice = Microservice> extends Inte
/**
* Shutdown the database service
*/
public async shutdown() {
public override async shutdown() {
await this.connection.close();
}


+ 3
- 3
packages/webserver/src/WebServerService.ts View File

@ -31,7 +31,7 @@ export abstract class WebServerService<M extends Microservice = Microservice> ex
/**
* Boot the webserver
*/
public async boot() {
public override async boot() {
// Create the Fastify instance
this.fastify = fastify();
@ -45,7 +45,7 @@ export abstract class WebServerService<M extends Microservice = Microservice> ex
/**
* Start the webserver
*/
public start() {
public override start() {
// Start listening
this.fastify.listen(this.PORT, "0.0.0.0");
this.log("Webserver listening on port:", this.PORT);
@ -54,7 +54,7 @@ export abstract class WebServerService<M extends Microservice = Microservice> ex
/**
* Shutdown the webserver
*/
public async shutdown() {
public override async shutdown() {
this.log("Webserver shutting down");
await this.fastify.close();
}


+ 5
- 5
packages/websocket-server/src/WebSocketServerService.ts View File

@ -19,7 +19,7 @@ export abstract class WebSocketServerService<M extends Microservice> extends Int
/**
* The list of registered methods
*/
#methods: { [method: string]: (payload?: any) => Promise<any>|any } = {};
private __methods: { [method: string]: (payload?: any) => Promise<any>|any } = {};
// Overridable ---------------------------------------------------------------------------------
@ -111,10 +111,10 @@ export abstract class WebSocketServerService<M extends Microservice> extends Int
* Install a method into the server service
*/
protected installMethod(name: string, method: (payload?: any) => Promise<any>|any) {
if (this.#methods[name] !== undefined) {
if (this.__methods[name] !== undefined) {
throw new Error("Attempted to install method with duplicate name in websocket service");
}
this.#methods[name] = method;
this.__methods[name] = method;
}
// Event Handling ------------------------------------------------------------------------------
@ -123,11 +123,11 @@ export abstract class WebSocketServerService<M extends Microservice> extends Int
* Handle an incoming request
*/
protected async handleRequest(socket: WebSocket, request: IWebSocketRequest) {
if (this.#methods[request.method] === undefined) {
if (this.__methods[request.method] === undefined) {
console.warn(`Requested unknown method: '${request.method}' with payload:`, request.payload);
return;
}
let result = await this.#methods[request.method](request.payload);
let result = await this.__methods[request.method](request.payload);
socket.send(JSON.stringify(<IWebSocketResponse>{
type: "response",
requestId: request.requestId,


Loading…
Cancel
Save