Skip to content

Commit

Permalink
Merge fe752f5 into 1902206
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-casarrubias committed Apr 25, 2018
2 parents 1902206 + fe752f5 commit daefaec
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
3 changes: 0 additions & 3 deletions src/core/app.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/app.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 2 additions & 7 deletions src/core/call.responser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AppConstructor, ReflectionKeys, IAppOperation} from '../interfaces';
import {ReflectionKeys, IAppOperation} from '../interfaces';
import {AppFactory, LifeCycle} from '../core';
/**
* @class CallResponse
Expand All @@ -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
Expand Down Expand Up @@ -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);
});
Expand Down
7 changes: 2 additions & 5 deletions src/core/call.streamer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AppFactory} from './app.factory';
import {AppConstructor, IAppOperation} from '../interfaces';
import {IAppOperation} from '../interfaces';
import {LifeCycle} from '.';
import {ReflectionKeys} from '..';

Expand All @@ -15,17 +15,14 @@ export class CallStreamer {
* @param factory
* @param AppClass
*/
constructor(private factory: AppFactory, private AppClass: AppConstructor) {}
constructor(private factory: AppFactory) {}
/**
* @method register
* @param operation
* @description This method will register an incoming call in order
* 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,
Expand Down
5 changes: 0 additions & 5 deletions src/core/host.broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions src/core/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class LifeCycle {
message: OnixMessage,
method: () => Promise<any>,
): Promise<any> {
console.log('Before App Method Call');
// Before Method Call
const result: any = await method();
// After Method Call
Expand All @@ -44,7 +43,6 @@ export class LifeCycle {
message: OnixMessage,
method: () => Promise<any>,
): Promise<any> {
console.log('Before Module Method Call');
// Before Method Call
const result: any = await method();
// After Method Call
Expand All @@ -65,7 +63,6 @@ export class LifeCycle {
message: OnixMessage,
method: () => Promise<any>,
): Promise<any> {
console.log('Before Component Method Call');
// Before Method Call
const result: any = await method();
// After Method Call
Expand All @@ -86,10 +83,8 @@ export class LifeCycle {
message: OnixMessage,
stream: (handler: (data) => any) => any,
): Promise<any> {
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;
});
Expand All @@ -109,11 +104,9 @@ export class LifeCycle {
message: OnixMessage,
stream: (handler: (data) => any) => any,
): Promise<any> {
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;
});
}
Expand Down
4 changes: 0 additions & 4 deletions src/core/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export namespace Roles {
* verification business logic. In this case any caller is allowed
*
async access(name: string, request: any): Promise<boolean> {
console.log(request);
return new Promise<boolean>((resolve, reject) => resolve(true));
}
}
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/core/schema.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down
9 changes: 1 addition & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -242,7 +242,6 @@ export class OnixJS {
*/
coordinate(rpc: string, request: IRequest) {
return new Promise<IAppOperation>((resolve, reject) => {
console.log('Onix server got remote call procedure');
const operation: IAppOperation = {
uuid: Utils.uuid(),
type: OperationType.ONIX_REMOTE_CALL_PROCEDURE,
Expand All @@ -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);
}
});
Expand Down
4 changes: 1 addition & 3 deletions test/alice.app/modules/alice.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
4 changes: 1 addition & 3 deletions test/bob.app/modules/bob.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
2 changes: 0 additions & 2 deletions test/onixjs.acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down
18 changes: 7 additions & 11 deletions test/onixjs.core.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand All @@ -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');
}
},
);
Expand All @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion test/todo.shared/todo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {EventEmitter} from 'events';
// before call
const result = await method();
// after call
console.log('Custom Logger: ', result);
return result;
},
})
Expand Down

0 comments on commit daefaec

Please sign in to comment.