From 6543d60019e235cf37b94cd897fb8453857e5003 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Sat, 3 Sep 2016 16:03:57 +0200 Subject: [PATCH] added docs --- .gitignore | 3 +- README.md | 14 +++++++- dist/index.d.ts | 2 +- dist/index.js | 5 ++- docs/book.json | 15 +++++++++ docs/index.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ ts/index.ts | 1 - 7 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 docs/book.json create mode 100644 docs/index.md diff --git a/.gitignore b/.gitignore index 2f0dc55..1088a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ coverage/ -docs/ +pages/ + diff --git a/README.md b/README.md index 1b95cd2..7a39e71 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ # smartsocket easy and secure websocket communication, Typescript ready -## Status +## Availabililty +[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsocket) +[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartsocket) +[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsocket) +[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsocket/docs) + +## Status for master [![build status](https://gitlab.com/pushrocks/smartsocket/badges/master/build.svg)](https://gitlab.com/pushrocks/smartsocket/commits/master) +[![coverage report](https://gitlab.com/pushrocks/smartsocket/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartsocket/commits/master) +[![Dependency Status](https://david-dm.org/pushrocks/smartsocket.svg)](https://david-dm.org/pushrocks/smartsocket) +[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartsocket/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartsocket/master/dependencies/npm) +[![bitHound Code](https://www.bithound.io/github/pushrocks/smartsocket/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartsocket) +[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) ## Usage We recommend the use of typescript. diff --git a/dist/index.d.ts b/dist/index.d.ts index 7016c5f..8ede4d7 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -2,4 +2,4 @@ export * from "./smartsocket.classes.smartsocket"; export * from "./smartsocket.classes.smartsocketclient"; export * from "./smartsocket.classes.socketfunction"; export * from "./smartsocket.classes.socketrole"; -export { allSocketConnections } from "./smartsocket.classes.socketconnection"; +export * from "./smartsocket.classes.socketconnection"; diff --git a/dist/index.js b/dist/index.js index c92720a..9f71d39 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8,7 +8,6 @@ __export(require("./smartsocket.classes.smartsocketclient")); // export further classes and objects __export(require("./smartsocket.classes.socketfunction")); __export(require("./smartsocket.classes.socketrole")); -var smartsocket_classes_socketconnection_1 = require("./smartsocket.classes.socketconnection"); -exports.allSocketConnections = smartsocket_classes_socketconnection_1.allSocketConnections; +__export(require("./smartsocket.classes.socketconnection")); // need something more exposed? Create an issue on GitLab! -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsc0JBQXNCO0FBQ3RCLGlCQUFjLG1DQUFtQyxDQUFDLEVBQUE7QUFDbEQsaUJBQWMseUNBQXlDLENBQUMsRUFBQTtBQUV4RCxxQ0FBcUM7QUFDckMsaUJBQWMsc0NBQXNDLENBQUMsRUFBQTtBQUNyRCxpQkFBYyxrQ0FBa0MsQ0FBQyxFQUFBO0FBQ2pELHFEQUFtQyx3Q0FBd0MsQ0FBQztBQUFwRSwyRkFBb0U7QUFFNUUsMERBQTBEIn0= \ No newline at end of file +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBRUEsc0JBQXNCO0FBQ3RCLGlCQUFjLG1DQUFtQyxDQUFDLEVBQUE7QUFDbEQsaUJBQWMseUNBQXlDLENBQUMsRUFBQTtBQUV4RCxxQ0FBcUM7QUFDckMsaUJBQWMsc0NBQXNDLENBQUMsRUFBQTtBQUNyRCxpQkFBYyxrQ0FBa0MsQ0FBQyxFQUFBO0FBQ2pELGlCQUFjLHdDQUF3QyxDQUFDLEVBQUE7QUFFdkQsMERBQTBEIn0= \ No newline at end of file diff --git a/docs/book.json b/docs/book.json new file mode 100644 index 0000000..2bd173f --- /dev/null +++ b/docs/book.json @@ -0,0 +1,15 @@ +{ + "structure": { + "readme": "index.md" + }, + "plugins": [ + "tonic", + "edit-link" + ], + "pluginsConfig": { + "edit-link": { + "base": "https://gitlab.com/pushrocks/npmts/edit/master/docs/", + "label": "Edit on GitLab" + } + } +} \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..7a39e71 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,88 @@ +# smartsocket +easy and secure websocket communication, Typescript ready + +## Availabililty +[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartsocket) +[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartsocket) +[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartsocket) +[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartsocket/docs) + +## Status for master +[![build status](https://gitlab.com/pushrocks/smartsocket/badges/master/build.svg)](https://gitlab.com/pushrocks/smartsocket/commits/master) +[![coverage report](https://gitlab.com/pushrocks/smartsocket/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartsocket/commits/master) +[![Dependency Status](https://david-dm.org/pushrocks/smartsocket.svg)](https://david-dm.org/pushrocks/smartsocket) +[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartsocket/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartsocket/master/dependencies/npm) +[![bitHound Code](https://www.bithound.io/github/pushrocks/smartsocket/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartsocket) +[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) +[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) + +## Usage +We recommend the use of typescript. +Under the hood we use socket.io and shortid for managed data exchange. + +### Serverside +```typescript +import * as smartsocket from "smartsocket"; + +let mySmartsocket = new smartsocket.Smartsocket({ + port: 3000 // the port smartsocket will listen on +}); + +let mySocketRole = new smartsocket.SocketRole({ + name: "someRoleName", + passwordHash: "someHashedString" +}); + +let testSocketFunction1 = new smartsocket.SocketFunction({ + funcName:"testSocketFunction1", + funcDef:(data) => { + + }, // the function to execute + allowedRoles:[mySocketRole] // all roles that have access to a specific function +}); + +mySmartsocket.clientCall("","restart",data,someTargetConnection) + .then((responseData) => { + + }); +``` + +#### Client side +```typescript +import * as smartsocket from "smartsocket"; + +let testSmartsocketClient = new smartsocket.SmartsocketClient({ + port: testConfig.port, + url: "http://localhost", + password: "testPassword", + alias: "testClient1", + role: "testRole1" +}); +testSmartsocketClient.connect() + .then(() => { + done(); + }); + +let testSocketFunction2 = new smartsocket.SocketFunction({ + funcName: "testSocketFunction2", + funcDef: (data) => {}, // the function to execute, has to return promise + allowedRoles:[] +}); + +let functionCalldata = { + funcName: "", + funcData: { + someKey:"someValue" + } +} + +mySmartsocketClient.serverCall("function",functionCallData) + .then((functionResponseData) => { // the functionResponseData comes from the server... awesome, right? + + });; +``` + +> **NOTE:** +you can easily chain dependent requests on either the server or client side with promises. +`data` is always a js object that you can design for your specific needs. +It supports buffers for large binary data network exchange. \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index b1157a6..daa7f2e 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -8,6 +8,5 @@ export * from "./smartsocket.classes.smartsocketclient"; export * from "./smartsocket.classes.socketfunction"; export * from "./smartsocket.classes.socketrole"; export * from "./smartsocket.classes.socketconnection"; -export {allSocketConnections} from "./smartsocket.classes.socketconnection"; // need something more exposed? Create an issue on GitLab!