From 712270ba6284b7c36baa217655df39895014e1e2 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 8 Apr 2019 19:56:21 +0200 Subject: [PATCH] fix(core): update --- npmextra.json | 2 +- package.json | 2 +- readme.md | 26 ++++++++++++++++++++++++++ test/test.ts | 15 +++++++++------ ts/index.ts | 16 ++++++++++------ ts/smartipc.plugins.ts | 10 ++-------- 6 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 readme.md diff --git a/npmextra.json b/npmextra.json index 6f24d7b..516d294 100644 --- a/npmextra.json +++ b/npmextra.json @@ -14,4 +14,4 @@ "npmGlobalTools": [], "npmAccessLevel": "public" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index a9a4555..9649e1d 100644 --- a/package.json +++ b/package.json @@ -27,4 +27,4 @@ "@types/node-ipc": "^9.1.1", "node-ipc": "^9.1.1" } -} +} \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7fb5e10 --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +# @pushrocks/smartipc +node inter process communication + +## Availabililty and Links +* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartipc) +* [gitlab.com (source)](https://gitlab.com/pushrocks/smartipc) +* [github.com (source mirror)](https://github.com/pushrocks/smartipc) +* [docs (typedoc)](https://pushrocks.gitlab.io/smartipc/) + +## Status for master +[![build status](https://gitlab.com/pushrocks/smartipc/badges/master/build.svg)](https://gitlab.com/pushrocks/smartipc/commits/master) +[![coverage report](https://gitlab.com/pushrocks/smartipc/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartipc/commits/master) +[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartipc.svg)](https://www.npmjs.com/package/@pushrocks/smartipc) +[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartipc/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartipc) +[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) +[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) + +## Usage + +For further information read the linked docs at the top of this readme. + +> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) +| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) + +[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com) diff --git a/test/test.ts b/test/test.ts index 5eccebc..4f8f978 100644 --- a/test/test.ts +++ b/test/test.ts @@ -11,14 +11,17 @@ tap.test('should instantiate a valid instance', async () => { ipcSpace: 'testSmartIpc', type: 'server' }); -}) - -tap.test('should create a client', async (tools) => { - + testIpc.start(); }); -tap.test('should terminate the smartipc process', async () => { - +tap.test('should create a client', async tools => { + const clientIpc = new smartipc.SmartIpc({ + ipcSpace: 'testSmartIpc', + type: 'client' + }); + clientIpc.sendMessage(); }); +tap.test('should terminate the smartipc process', async () => {}); + tap.start(); diff --git a/ts/index.ts b/ts/index.ts index 2cf2069..75e0916 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -9,13 +9,13 @@ export interface ISmartIpcConstructorOptions { ipcSpace: string; } - export interface ISmartIpcHandlerPackage { keyword: string; handlerFunc: () => void; } export class SmartIpc { + public ipc = new plugins.nodeIpc.IPC(); public handlers: ISmartIpcHandlerPackage[] = []; public options: ISmartIpcConstructorOptions; @@ -23,22 +23,21 @@ export class SmartIpc { this.options = optionsArg; } - /** * connect to the channel */ public async start() { switch (this.options.type) { case 'server': - plugins.nodeIpc.config.id = this.options.ipcSpace; + this.ipc.config.id = this.options.ipcSpace; const done = plugins.smartpromise.defer(); - plugins.nodeIpc.serve(() => { + this.ipc.serve(() => { done.resolve(); }); await done.promise; break; case 'client': - plugins.nodeIpc.connectTo(this.options.ipcSpace); + this.ipc.connectTo(this.options.ipcSpace); default: throw new Error('type of ipc is not valid. Must be "server" or "client"'); } @@ -54,7 +53,12 @@ export class SmartIpc { /** * regsiters a handler */ - registerHandler (handlerPackage: ISmartIpcHandlerPackage) { + registerHandler(handlerPackage: ISmartIpcHandlerPackage) { this.handlers.push(handlerPackage); } + + sendMessage() { + switch (this.options.type) { + } + } } diff --git a/ts/smartipc.plugins.ts b/ts/smartipc.plugins.ts index 53b1656..5c14e71 100644 --- a/ts/smartipc.plugins.ts +++ b/ts/smartipc.plugins.ts @@ -2,15 +2,9 @@ import * as smartpromise from '@pushrocks/smartpromise'; import * as smartrx from '@pushrocks/smartrx'; -export { - smartpromise, - smartrx -}; +export { smartpromise, smartrx }; // third party scope import * as nodeIpc from 'node-ipc'; -export { - nodeIpc -}; - +export { nodeIpc };