Skip to content

Commit

Permalink
Release 1.0.0-beta.1 🚀
Browse files Browse the repository at this point in the history
GitHub Milestone: https://github.com/onixjs/core/milestone/2?closed=1

- Fix: #43
- Fix: #42
- Fix: #41
  • Loading branch information
Jonathan committed May 19, 2018
1 parent 2d52bb0 commit ba16688
Show file tree
Hide file tree
Showing 19 changed files with 425 additions and 257 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"build:watch": "tsc --watch",
"build:docs": "typedoc --out ./documentation ./src",
"clean": "rm -rf dist dist6",
"lint": "npm run prettier:check && npm run lint:fix && npm run tslint",
"lint": "npm run prettier:fix && npm run prettier:check && npm run lint:fix && npm run tslint",
"lint:fix": "npm run prettier:fix",
"prettier:cli": "prettier \"**/*.ts\" \"**/*.js\"",
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
"tslint": "tslint -c tslint.full.json --project tsconfig.json --type-check",
"tslint": "tslint -c tslint.full.json --project tsconfig.json",
"tslint:fix": "npm run lint -- --fix",
"prepublish": "npm run lint:fix && npm run clean && npm run build",
"pretest": "npm run build",
Expand Down Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@onixjs/enumerable": "1.0.0-alpha.7",
"@onixjs/sdk": "^1.0.0-alpha.14",
"@onixjs/sdk": "^1.0.0-beta.1",
"finalhandler": "^1.1.1",
"reflect-metadata": "^0.1.12",
"router": "^1.3.2"
Expand Down
2 changes: 1 addition & 1 deletion src/core/acl.group.match.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
IAppOperation,
IComponentConfig,
promiseSeries,
IACLRule,
IGroup,
Injector,
IModuleConfig,
} from '..';
import {IAppOperation} from '@onixjs/sdk';
/**
* @class GroupMatch
* @author Joanthan Casarrubias
Expand Down
3 changes: 2 additions & 1 deletion src/core/acl.groups.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {IRequest, AccessType, IGroup} from '../interfaces';
import {AccessType, IGroup} from '../interfaces';
import {IRequest} from '@onixjs/sdk';
/**
* @namespace Groups
* @author Jonathan Casarrubias
Expand Down
70 changes: 48 additions & 22 deletions src/core/app.server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import 'reflect-metadata';
import {
OperationType,
IAppOperation,
IAppConfig,
AppConstructor,
} from '../index';
import {IAppConfig, AppConstructor} from '../index';
import {AppFactory} from './app.factory';
import {CallResponser} from './call.responser';
import {CallStreamer} from './call.streamer';
Expand All @@ -14,6 +9,8 @@ import * as fs from 'fs';
import * as http from 'http';
import * as https from 'https';
import * as finalhandler from 'finalhandler';
import {IAppOperation, OperationType} from '@onixjs/sdk';
import {NotifyEvents} from './notify.events';
/**
* @function AppServer
* @author Jonathan Casarrubias
Expand Down Expand Up @@ -121,17 +118,24 @@ export class AppServer {
// Setup responser and streamer
this.responser = new CallResponser(this.factory);
this.streamer = new CallStreamer(this.factory);
// Return IO Stream Message
if (process.send) {
process.send({
uuid: operation.uuid,
type: OperationType.APP_CREATE_RESPONSE,
message: {
request: {
payload: schema,
try {
// Return IO Stream Message
if (process.send) {
process.send({
uuid: operation.uuid,
type: OperationType.APP_CREATE_RESPONSE,
message: {
request: {
payload: schema,
},
},
},
});
});
}
} catch (e) {
console.log(
'ONIXJS: HostBroker is not available, this process is going down.',
);
process.kill(1);
}
break;
// Event sent from the broker when starting a project
Expand All @@ -150,6 +154,32 @@ export class AppServer {
if (process.send)
process.send({type: OperationType.APP_START_RESPONSE});
break;
// Event sent from the broker when a client has been disconnected
case OperationType.ONIX_REMOTE_UNREGISTER_CLIENT:
this.notifier.emit(
NotifyEvents.CLIENT_CLOSED,
operation.message.request.metadata.subscription,
);
// Send back result
if (process.send)
process.send({
uuid: operation.uuid,
type: OperationType.ONIX_REMOTE_UNREGISTER_CLIENT_RESPONSE,
});
break;
// Event sent from the broker when a client has been disconnected
case OperationType.ONIX_REMOTE_CALL_STREAM_UNSUBSCRIBE:
this.notifier.emit(
NotifyEvents.CLIENT_UNSUBSCRIBED,
operation.message.request.payload.uuid,
);
// Send back result
if (process.send)
process.send({
uuid: operation.uuid,
type: OperationType.ONIX_REMOTE_CALL_STREAM_UNSUBSCRIBE_RESPONSE,
});
break;
// Event sent from the broker when stoping a project
case OperationType.APP_STOP:
// If network enabled, turn off the server
Expand Down Expand Up @@ -177,9 +207,7 @@ export class AppServer {
message: {
rpc: operation.message.rpc,
request: {
metadata: {
/* HERE We might want to return server-side metadata*/
},
metadata: operation.message.request.metadata,
payload: chunk,
},
},
Expand All @@ -196,9 +224,7 @@ export class AppServer {
message: {
rpc: operation.message.rpc,
request: {
metadata: {
/* HERE We might want to return server-side metadata*/
},
metadata: operation.message.request.metadata,
payload: result,
},
},
Expand Down
22 changes: 13 additions & 9 deletions src/core/call.connect.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import {
IAppOperation,
OperationType,
IMetaData,
ICallConfig,
IOnixSchema,
} from '../interfaces';
import {ICallConfig, IOnixSchema} from '../interfaces';
import {Utils} from '@onixjs/sdk/dist/utils';
import {NodeJS} from '@onixjs/sdk/dist/adapters/node.adapters';
import {IAppOperation, OperationType, IMetaData} from '@onixjs/sdk';
/**
* @class CallConnect
* @author Jonathan Casarrubias
Expand Down Expand Up @@ -66,7 +61,13 @@ export class CallConnect {
* execute a RPC, that can be either on this SOA Service or within
* any other SOA Service living in the same cluster.
*/
async call<T>(payload: T, metadata: IMetaData = {stream: false}): Promise<T> {
async call<T>(
payload: T,
metadata: IMetaData = {
stream: false,
subscription: '$anonymous',
},
): Promise<T> {
// Hard copy the configuration
const config: ICallConfig = JSON.parse(JSON.stringify(this.config));
// Make sure everything is well configured in order to make this call
Expand Down Expand Up @@ -118,7 +119,10 @@ export class CallConnect {
*/
async stream<T>(
handler: (payload: T, metadata: IMetaData) => void,
metadata: IMetaData = {stream: true},
metadata: IMetaData = {
stream: true,
subscription: '$anonymous',
},
) {
// Hard copy the configuration
const config: ICallConfig = JSON.parse(JSON.stringify(this.config));
Expand Down
8 changes: 2 additions & 6 deletions src/core/call.responser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
ReflectionKeys,
IAppOperation,
IComponentConfig,
IModuleConfig,
} from '../interfaces';
import {ReflectionKeys, IComponentConfig, IModuleConfig} from '../interfaces';
import {AppFactory, LifeCycle} from '../core';
import {GroupMatch} from './acl.group.match';
import {IAppOperation} from '@onixjs/sdk';
//import { RoleMatch } from './roles';
/**
* @class CallResponse
Expand Down
5 changes: 4 additions & 1 deletion src/core/call.streamer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {AppFactory} from './app.factory';
import {IAppOperation, IComponentConfig, IModuleConfig} from '../interfaces';
import {IComponentConfig, IModuleConfig} from '../interfaces';
import {LifeCycle} from '.';
import {ReflectionKeys} from '..';
import {GroupMatch} from './acl.group.match';
import {IAppOperation} from '@onixjs/sdk';

export class CallStreamer {
/**
Expand Down Expand Up @@ -118,6 +119,7 @@ export class CallStreamer {
scope,
data => handler(slaveSubHandler(masterSubHandler(data))),
operation.message.request.metadata,
operation.uuid,
)
: null;
},
Expand All @@ -129,6 +131,7 @@ export class CallStreamer {
scope,
data => handler(masterSubHandler(data)),
operation.message.request.metadata,
operation.uuid,
)
: null;
}
Expand Down
Loading

0 comments on commit ba16688

Please sign in to comment.