Skip to content

Commit

Permalink
Release 1.0.0-alpha.7.2 WIP
Browse files Browse the repository at this point in the history
- Increased test coverage
- Deprecated UUID
- Partially implemented SDK Utils
  • Loading branch information
Jonathan committed Mar 21, 2018
1 parent d74d94a commit e80eb06
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 131 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OnixJS - FrameWork [![Beerpay](https://beerpay.io/onixjs/core/badge.svg?style=beer)](https://beerpay.io/onixjs/core) [![Beerpay](https://beerpay.io/onixjs/core/make-wish.svg?style=flat)](https://beerpay.io/onixjs/core?focus=wish) [![Travis](https://img.shields.io/travis/onixjs/core.svg)](https://travis-ci.org/onixjs/core) [![npm (scoped)](https://img.shields.io/npm/v/@onixjs/core.svg)](npmjs.com/package/@onixjs/core) [![Coveralls github](https://img.shields.io/coveralls/github/onixjs/core/development.svg)](https://coveralls.io/github/onixjs/core)
OnixJS - FrameWork [![Beerpay](https://beerpay.io/onixjs/core/badge.svg?style=beer)](https://beerpay.io/onixjs/core) [![Beerpay](https://beerpay.io/onixjs/core/make-wish.svg?style=flat)](https://beerpay.io/onixjs/core?focus=wish) [![Coverage Status](https://coveralls.io/repos/github/onixjs/core/badge.svg?branch=master)](https://coveralls.io/github/onixjs/core?branch=development) [![Travis](https://img.shields.io/travis/onixjs/core.svg)](https://travis-ci.org/onixjs/core) [![npm (scoped)](https://img.shields.io/npm/v/@onixjs/core.svg)](http://npmjs.com/package/@onixjs/core)
================
![alt text](https://raw.githubusercontent.com/onixjs/core/master/misc/onix-splash.png "OnixJS")

Expand Down Expand Up @@ -63,8 +63,8 @@ $ npm install && npm run test
## Contributors

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars0.githubusercontent.com/u/1533239?v=3" width="100px;"/><br /><sub>Jonathan Casarrubias</sub>](http://mean.expert/)<br />[💻](https://github.com/onixjs/core/commits?author=jonathan-casarrubias) | | | | | |
| :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars0.githubusercontent.com/u/1533239?v=3" width="100px;"/><br /><sub>Jonathan Casarrubias</sub>](http://mean.expert/)<br />[💻](https://github.com/onixjs/core/commits?author=jonathan-casarrubias) |
| :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onixjs/core",
"version": "1.0.0-alpha.7.1",
"version": "1.0.0-alpha.7.2",
"description": "The High-Performance SOA Real-Time Framework for Node.JS",
"main": "dist/src/index.js",
"scripts": {
Expand Down Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"reflect-metadata": "^0.1.12",
"uuid": "^3.2.1",
"@onixjs/sdk": "^1.0.0-alpha.4.1",
"uws": "^9.14.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/core/app.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Constructor,
AppConstructor,
} from '../interfaces';
import {OnixRPC, Injector} from '../core';
import {Injector} from '../core';
import {getObjectMethods} from '../utils';
/**
* @class AppFactory
Expand Down Expand Up @@ -39,7 +39,7 @@ export class AppFactory {
*/
constructor(private Class: AppConstructor, private config: IAppConfig) {
// First of all create a new class instance
if (!this.app) this.app = new this.Class(new OnixRPC(this.Class));
if (!this.app) this.app = new this.Class();
// Now setup its modules
this.setupModules();
// Once finished send the schema back
Expand Down
8 changes: 5 additions & 3 deletions src/core/app.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ export class AppServer {
apps.map(
(name: string) =>
new Promise<boolean>(async (resolve, reject) => {
const result: boolean = await this.factory.app.rpc
.topic(`${name}.isAlive`)
.call();
const result: boolean = await this.responser.process(<ICall>{
uuid: '1',
rpc: `${name}.isAlive`,
request: {metadata: {}, payload: {}},
});
resolve(result);
}),
),
Expand Down
16 changes: 8 additions & 8 deletions src/core/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IApp, OnixRPC, IAppConfig, IModuleDirectory} from '../index';
import {IApp, IAppConfig, IModuleDirectory} from '../index';
/**
* @class App
* @author Jonathan Casarrubias
Expand Down Expand Up @@ -27,14 +27,14 @@ export class Application implements IApp {
* Receives optional configurations as parameter.
* Otherwise will use platform default configuration.
*/
constructor(public rpc: OnixRPC) {}
constructor() {}
/**
* @method start
* @description Mock start method, this might be replaced
* by custom App level functionality
*/
async start(): Promise<null> {
return new Promise<null>((resolve, reject) => {
async start(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
Object.keys(this.modules).forEach((moduleName: string) => {
Object.keys(this.modules[moduleName]).forEach(
(componentName: string) => {
Expand All @@ -46,16 +46,16 @@ export class Application implements IApp {
},
);
});
resolve();
resolve(true);
});
}
/**
* @method stop
* @description Mock stop method, this might be replaced
* by custom App level functionality
*/
async stop(): Promise<null> {
return new Promise<null>((resolve, reject) => {
async stop(): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
Object.keys(this.modules).forEach((moduleName: string) => {
Object.keys(this.modules[moduleName]).forEach(
(componentName: string) => {
Expand All @@ -68,7 +68,7 @@ export class Application implements IApp {
},
);
});
resolve();
resolve(true);
});
}
}
4 changes: 3 additions & 1 deletion src/core/call.streamer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export class CallStreamer {
const segments: string[] = message.rpc.split('.');
// Component level method, RPC Exposed
if (segments.length !== 4) {
return handler(new Error(`RPC Call is invalid ${message.rpc}`));
return handler(
new Error(`OnixJS Error: RPC Call is invalid "${message.rpc}"`),
);
}
// Execute main hook, might be app/system or module level.
this.factory.app.modules[segments[1]][segments[2]][segments[3]](handler);
Expand Down
3 changes: 0 additions & 3 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export * from './app';
export * from './rpc';
//xport * from './roles';
//export * from './acl.rule';
export * from './injector';
export * from './lifecycle';
export * from './connection';
Expand Down
70 changes: 0 additions & 70 deletions src/core/rpc.ts

This file was deleted.

14 changes: 3 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
OnixConfig,
} from './interfaces';
import {SchemaProvider} from './core/schema.provider';
import * as uuid from 'uuid';
// Export all core modules & interfaces
export * from './core';
export * from './utils';
export * from './decorators';
export * from './interfaces';
import {Utils} from '@onixjs/sdk/dist/utils';
/**
* @class OnixJS
* @author Jonathan Casarrubias <gh: mean-expert-official>
Expand All @@ -33,7 +33,7 @@ export class OnixJS {
* @description Current Onix Version.
*/
get version(): string {
return '1.0.0-alpha.7.1';
return '1.0.0-alpha.7.2';
}
/**
* @property server
Expand Down Expand Up @@ -148,14 +148,6 @@ export class OnixJS {
this._apps[name].config = operation.message;
resolve(this._apps[name].process);
break;
case OperationType.ONIX_REMOTE_CALL_PROCEDURE:
this._apps[name].process.send(
await this.coordinate(
(<ICall>operation.message).rpc,
(<ICall>operation.message).request,
),
);
break;
}
},
);
Expand Down Expand Up @@ -185,7 +177,7 @@ export class OnixJS {
return new Promise<IAppOperation>((resolve, reject) => {
console.log('Onix server got remote call procedure');
const operation: IAppOperation = {
uuid: uuid(),
uuid: Utils.uuid(),
type: OperationType.ONIX_REMOTE_CALL_PROCEDURE,
message: <ICall>{
rpc,
Expand Down
8 changes: 3 additions & 5 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {ChildProcess} from 'child_process';
import {OnixRPC} from '../index';
import * as http from 'http';
/**
* @interface IAppConfig
Expand All @@ -20,7 +19,7 @@ export interface IAppConfig extends DomainConfig {
* that receives a OnixRPC class.
*/
export interface AppConstructor {
new (rpc: OnixRPC): IApp;
new (): IApp;
}
/**
* @interface IModuleConfig
Expand Down Expand Up @@ -111,9 +110,8 @@ export interface IInjectable {
*/
export interface IApp {
modules: IModuleDirectory;
rpc: OnixRPC;
start(): Promise<null>;
stop(): Promise<null>;
start(): Promise<boolean>;
stop(): Promise<boolean>;
isAlive(): boolean;
}
/**
Expand Down
9 changes: 0 additions & 9 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,3 @@ function iterateObject(obj, next) {
proto = Object.getPrototypeOf(proto);
}
}

export function isJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
Loading

0 comments on commit e80eb06

Please sign in to comment.