From fe752f5ca0d7c51e700b0fac6c8dabd5703979bd Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 25 Apr 2018 14:56:55 -0500 Subject: [PATCH] Release 1.0.0-alpha.20.1 :book: - Cleaned up project - Removed all console.logs (Todo implement own debug util) --- package.json | 2 +- src/core/app.factory.ts | 3 --- src/core/app.server.ts | 4 ++-- src/core/call.responser.ts | 9 ++------- src/core/call.streamer.ts | 7 ++----- src/core/host.broker.ts | 5 ----- src/core/lifecycle.ts | 7 ------- src/core/roles.ts | 4 ---- src/core/schema.provider.ts | 1 - src/index.ts | 9 +-------- test/alice.app/modules/alice.component.ts | 4 +--- test/bob.app/modules/bob.component.ts | 4 +--- test/onixjs.acceptance.ts | 2 -- test/onixjs.core.unit.ts | 18 +++++++----------- test/todo.shared/todo.component.ts | 1 - 15 files changed, 17 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index 772d2f5..6505ec9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onixjs/core", - "version": "1.0.0-alpha.20", + "version": "1.0.0-alpha.20.1", "description": "An Enterprise Grade NodeJS Platform that implements Industry Standards and Patterns in order to provide Connectivity, Stability, High-Availability and High-Performance.", "main": "dist/src/index.js", "scripts": { diff --git a/src/core/app.factory.ts b/src/core/app.factory.ts index 7f1001e..8d5b927 100644 --- a/src/core/app.factory.ts +++ b/src/core/app.factory.ts @@ -347,9 +347,6 @@ export class AppFactory { if (!exist) { // if the file is not found, return 404 res.statusCode = 404; - console.log( - `ONIXJS Error: The configured pathfile "${pathname}" does not exist`, - ); return res.end( JSON.stringify({ code: res.statusCode, diff --git a/src/core/app.server.ts b/src/core/app.server.ts index 1e38408..5217112 100644 --- a/src/core/app.server.ts +++ b/src/core/app.server.ts @@ -119,8 +119,8 @@ export class AppServer { this.factory.notifier = this.notifier; const schema: any = await this.factory.setup(); // Setup responser and streamer - this.responser = new CallResponser(this.factory, this.AppClass); - this.streamer = new CallStreamer(this.factory, this.AppClass); + this.responser = new CallResponser(this.factory); + this.streamer = new CallStreamer(this.factory); // Return IO Stream Message if (process.send) { process.send({ diff --git a/src/core/call.responser.ts b/src/core/call.responser.ts index 38d1e1c..cefdb88 100644 --- a/src/core/call.responser.ts +++ b/src/core/call.responser.ts @@ -1,4 +1,4 @@ -import {AppConstructor, ReflectionKeys, IAppOperation} from '../interfaces'; +import {ReflectionKeys, IAppOperation} from '../interfaces'; import {AppFactory, LifeCycle} from '../core'; /** * @class CallResponse @@ -19,7 +19,7 @@ export class CallResponser { * @param factory * @param AppClass */ - constructor(private factory: AppFactory, private AppClass: AppConstructor) {} + constructor(private factory: AppFactory) {} /** * @method process * @param operation @@ -116,11 +116,6 @@ export class CallResponser { } }, ); - // Log result - console.log( - `Onix callee app ${this.AppClass.name} sending rpc result`, - result, - ); // Resolve promise resolve(result); }); diff --git a/src/core/call.streamer.ts b/src/core/call.streamer.ts index 1d4adff..87804c1 100644 --- a/src/core/call.streamer.ts +++ b/src/core/call.streamer.ts @@ -1,5 +1,5 @@ import {AppFactory} from './app.factory'; -import {AppConstructor, IAppOperation} from '../interfaces'; +import {IAppOperation} from '../interfaces'; import {LifeCycle} from '.'; import {ReflectionKeys} from '..'; @@ -15,7 +15,7 @@ export class CallStreamer { * @param factory * @param AppClass */ - constructor(private factory: AppFactory, private AppClass: AppConstructor) {} + constructor(private factory: AppFactory) {} /** * @method register * @param operation @@ -23,9 +23,6 @@ export class CallStreamer { * to send back an answer. */ register(operation: IAppOperation, handler) { - console.log( - `Onix callee app ${this.AppClass.name} got remote stream request`, - ); // Get segments from rpc endpoint let scope, method: Function | null = null, diff --git a/src/core/host.broker.ts b/src/core/host.broker.ts index dfb235a..d4caddc 100644 --- a/src/core/host.broker.ts +++ b/src/core/host.broker.ts @@ -33,11 +33,6 @@ export class HostBroker { handle(ws: WebSocket, operation: IAppOperation) { // Route Message to the right application const callee: string = operation.message.rpc.split('.').shift() || ''; - console.log( - 'Onix server caller: ', - operation.message.request.metadata.caller, - ); - console.log('Onix server callee: ', callee); if (this.apps[callee]) { this.apps[callee].process.on('message', (response: IAppOperation) => { if (operation.uuid === response.uuid) { diff --git a/src/core/lifecycle.ts b/src/core/lifecycle.ts index 2c368fe..1ca46b4 100644 --- a/src/core/lifecycle.ts +++ b/src/core/lifecycle.ts @@ -23,7 +23,6 @@ export class LifeCycle { message: OnixMessage, method: () => Promise, ): Promise { - console.log('Before App Method Call'); // Before Method Call const result: any = await method(); // After Method Call @@ -44,7 +43,6 @@ export class LifeCycle { message: OnixMessage, method: () => Promise, ): Promise { - console.log('Before Module Method Call'); // Before Method Call const result: any = await method(); // After Method Call @@ -65,7 +63,6 @@ export class LifeCycle { message: OnixMessage, method: () => Promise, ): Promise { - console.log('Before Component Method Call'); // Before Method Call const result: any = await method(); // After Method Call @@ -86,10 +83,8 @@ export class LifeCycle { message: OnixMessage, stream: (handler: (data) => any) => any, ): Promise { - console.log('Before Module Method Stream'); // Before Method Stream (Do something with request) stream(data => { - console.log('After Module Method Stream', data); // Afet method stream return data; }); @@ -109,11 +104,9 @@ export class LifeCycle { message: OnixMessage, stream: (handler: (data) => any) => any, ): Promise { - console.log('Before Component Method Stream'); // Before Method Stream (Do something with request) stream(data => { // Afet method stream - console.log('After Component Method Stream', data); return data; }); } diff --git a/src/core/roles.ts b/src/core/roles.ts index 28f0807..a8b4784 100644 --- a/src/core/roles.ts +++ b/src/core/roles.ts @@ -23,7 +23,6 @@ export namespace Roles { * verification business logic. In this case any caller is allowed * async access(name: string, request: any): Promise { - console.log(request); return new Promise((resolve, reject) => resolve(true)); } } @@ -50,9 +49,6 @@ export class RoleMatch { ); // Every RPC Method is closed by default, if there are no rules, then there is no access if (rules.length === 0) { - console.log( - `Onix RoleMatch verification fail for method ${name}, no acl rules were found.`, - ); resolve(false); } // If there are rules for this method then lets execute those diff --git a/src/core/schema.provider.ts b/src/core/schema.provider.ts index f17a951..d4a3089 100644 --- a/src/core/schema.provider.ts +++ b/src/core/schema.provider.ts @@ -35,7 +35,6 @@ export class SchemaProvider { res.setHeader('Content-Type', 'application/json'); res.writeHead(200, {'Content-Type': 'application/json'}); const schema = JSON.stringify(configs); - console.log('THE GOD DAMN SCHEMA: ', schema); res.end(schema); }); } diff --git a/src/index.ts b/src/index.ts index ffeb0cf..5710750 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,7 +39,7 @@ export class OnixJS { * @description Current Onix Version. */ get version(): string { - return '1.0.0-alpha.20'; + return '1.0.0-alpha.20.1'; } /** * @property router @@ -242,7 +242,6 @@ export class OnixJS { */ coordinate(rpc: string, request: IRequest) { return new Promise((resolve, reject) => { - console.log('Onix server got remote call procedure'); const operation: IAppOperation = { uuid: Utils.uuid(), type: OperationType.ONIX_REMOTE_CALL_PROCEDURE, @@ -252,17 +251,11 @@ export class OnixJS { }, }; const callee: string = rpc.split('.').shift() || ''; - console.log('Onix server caller: ', request.metadata.caller); - console.log('Onix server callee: ', callee); if (this._apps[callee]) { this._apps[callee].process.on('message', (response: IAppOperation) => { if ( response.type === OperationType.ONIX_REMOTE_CALL_PROCEDURE_RESPONSE ) { - console.log( - `Onix server response from callee (${callee}): `, - response.message, - ); resolve(response); } }); diff --git a/test/alice.app/modules/alice.component.ts b/test/alice.app/modules/alice.component.ts index 6912608..6bac784 100644 --- a/test/alice.app/modules/alice.component.ts +++ b/test/alice.app/modules/alice.component.ts @@ -7,8 +7,6 @@ import {IComponent} from '../../../src/index'; * for testing purposes, storing Alice objects in memory. */ export class AliceComponent implements IComponent { - init() { - console.log('Bob Component is Alive'); - } + init() {} destroy() {} } diff --git a/test/bob.app/modules/bob.component.ts b/test/bob.app/modules/bob.component.ts index 6af77b9..567aa72 100644 --- a/test/bob.app/modules/bob.component.ts +++ b/test/bob.app/modules/bob.component.ts @@ -7,8 +7,6 @@ import {IComponent} from '../../../src/index'; * for testing purposes, storing Bob objects in memory. */ export class BobComponent implements IComponent { - init() { - console.log('Bob Component is Alive'); - } + init() {} destroy() {} } diff --git a/test/onixjs.acceptance.ts b/test/onixjs.acceptance.ts index 3cfdd39..e3402ab 100644 --- a/test/onixjs.acceptance.ts +++ b/test/onixjs.acceptance.ts @@ -96,8 +96,6 @@ test('Onix rpc component methods from client', async t => { t.truthy(operation.message.request.payload._id); await onix.stop(); } - } else { - console.log('NO VALID JSON DATA: ', data); } }); diff --git a/test/onixjs.core.unit.ts b/test/onixjs.core.unit.ts index 622fb61..985901e 100644 --- a/test/onixjs.core.unit.ts +++ b/test/onixjs.core.unit.ts @@ -47,8 +47,7 @@ test('Core: AppFactory creates an Application.', async t => { const instance: AppFactory = new AppFactory(MyApp); instance.config = {modules: []}; instance.notifier = new AppNotifier(); - const result = await instance.setup(); - console.log('A RESULT: ', result); + await instance.setup(); t.truthy(instance.app.start); t.truthy(instance.app.stop); t.truthy(instance.app.isAlive); @@ -159,7 +158,7 @@ test('Core: CallResponser invalid call.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const responser: CallResponser = new CallResponser(factory, MyApp); + const responser: CallResponser = new CallResponser(factory); const error = await t.throws( responser.process({ uuid: Utils.uuid(), @@ -195,7 +194,7 @@ test('Core: CallResponser invalid call.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const responser: CallResponser = new CallResponser(factory, MyApp); + const responser: CallResponser = new CallResponser(factory); const error = await t.throws( responser.process({ uuid: Utils.uuid(), @@ -231,7 +230,7 @@ test('Core: CallResponser invalid call.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const responser: CallResponser = new CallResponser(factory, MyApp); + const responser: CallResponser = new CallResponser(factory); const error = await t.throws( responser.process({ uuid: Utils.uuid(), @@ -273,7 +272,7 @@ test('Core: CallResponser Hooks.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const responser: CallResponser = new CallResponser(factory, MyApp); + const responser: CallResponser = new CallResponser(factory); const result = await responser.process({ uuid: Utils.uuid(), type: OperationType.ONIX_REMOTE_CALL_PROCEDURE, @@ -318,7 +317,7 @@ test('Core: CallResponser Hooks.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const streamer: CallStreamer = new CallStreamer(factory, MyApp); + const streamer: CallStreamer = new CallStreamer(factory); streamer.register( { uuid: Utils.uuid(), @@ -333,10 +332,7 @@ test('Core: CallResponser Hooks.', async t => { }, result => { if (result) { - console.log('THE STREAM RESULT', result); t.is(result.text, 'Hello Streamer'); - } else { - console.log('WHY IS RUNNING 2 TIMES'); } }, ); @@ -357,7 +353,7 @@ test('Core: CallStreamer invalid call.', async t => { factory.config = {network: {disabled: true}, modules: [MyModule]}; factory.notifier = new AppNotifier(); await factory.setup(); - const streamer: CallStreamer = new CallStreamer(factory, MyApp); + const streamer: CallStreamer = new CallStreamer(factory); streamer.register( { uuid: Utils.uuid(), diff --git a/test/todo.shared/todo.component.ts b/test/todo.shared/todo.component.ts index e0de3d2..627cc60 100644 --- a/test/todo.shared/todo.component.ts +++ b/test/todo.shared/todo.component.ts @@ -21,7 +21,6 @@ import {EventEmitter} from 'events'; // before call const result = await method(); // after call - console.log('Custom Logger: ', result); return result; }, })