fix(core): update

This commit is contained in:
Philipp Kunz 2019-04-23 00:28:57 +02:00
parent a8a91b4db2
commit b1017121ea
10 changed files with 112 additions and 180 deletions

181
package-lock.json generated
View File

@ -14,6 +14,26 @@
"nan": "^2.9.2"
}
},
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
"dev": true,
"requires": {
"@babel/highlight": "^7.0.0"
}
},
"@babel/highlight": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz",
"integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==",
"dev": true,
"requires": {
"chalk": "^2.0.0",
"esutils": "^2.0.2",
"js-tokens": "^4.0.0"
}
},
"@gitzone/tsbuild": {
"version": "2.1.8",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.8.tgz",
@ -296,20 +316,13 @@
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
},
"@pushrocks/smartrequest": {
"version": "1.1.14",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.14.tgz",
"integrity": "sha512-+sDQB4Mxvpn8BIMPUQ7TPSCKUVMln3tHC4rp4pmfEHmBQK+g1XwtNr59aMA9kEoBDMt7li1hu+1cs+SNsWt6Gw==",
"version": "1.1.15",
"resolved": "https://registry.npmjs.org/@pushrocks/smartrequest/-/smartrequest-1.1.15.tgz",
"integrity": "sha512-MBOOTTdqWy+HvWS4Lt8jzITxF2hYyQ3/OjB28CpTAkPuKsDyLi9HEngvFufKu5EbKwBGwCVdeF7vQSpLRSoDtA==",
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartpromise": "^3.0.2",
"@types/form-data": "^2.2.1",
"form-data": "^2.3.2"
},
"dependencies": {
"@pushrocks/smartpromise": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-2.0.5.tgz",
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g=="
}
"form-data": "^2.3.3"
}
},
"@pushrocks/smartrx": {
@ -533,9 +546,9 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "11.13.4",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-11.13.4.tgz",
"integrity": "sha512-+rabAZZ3Yn7tF/XPGHupKIL5EcAbrLxnTr/hgQICxbeuAfWtT0UZSfULE+ndusckBItcv4o6ZeOJplQikVcLvQ=="
"version": "11.13.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.6.tgz",
"integrity": "sha512-Xoo/EBzEe8HxTSwaZNLZjaW6M6tA/+GmD3/DZ6uo8qSaolE/9Oarko0oV1fVfrLqOz0tx0nXJB4rdD5c+vixLw=="
},
"@types/range-parser": {
"version": "1.2.3",
@ -643,10 +656,13 @@
"dev": true
},
"ansi-styles": {
"version": "2.2.1",
"resolved": "https://verdaccio.lossless.one/ansi-styles/-/ansi-styles-2.2.1.tgz",
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
"dev": true
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"arg": {
"version": "4.1.0",
@ -711,47 +727,6 @@
"resolved": "https://verdaccio.lossless.one/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://verdaccio.lossless.one/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
"integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=",
"dev": true,
"requires": {
"chalk": "^1.1.3",
"esutils": "^2.0.2",
"js-tokens": "^3.0.2"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
},
"chalk": {
"version": "1.1.3",
"resolved": "https://verdaccio.lossless.one/chalk/-/chalk-1.1.3.tgz",
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"dev": true,
"requires": {
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
}
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "https://verdaccio.lossless.one/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
}
}
}
},
"backo2": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/backo2/-/backo2-1.0.2.tgz",
@ -836,7 +811,7 @@
},
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://verdaccio.lossless.one/builtin-modules/-/builtin-modules-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
"dev": true
},
@ -897,33 +872,13 @@
},
"chalk": {
"version": "2.4.2",
"resolved": "https://verdaccio.lossless.one/chalk/-/chalk-2.4.2.tgz",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://verdaccio.lossless.one/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://verdaccio.lossless.one/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
}
}
},
"check-error": {
@ -976,7 +931,7 @@
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://verdaccio.lossless.one/color-convert/-/color-convert-1.9.3.tgz",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
@ -985,7 +940,7 @@
},
"color-name": {
"version": "1.1.3",
"resolved": "https://verdaccio.lossless.one/color-name/-/color-name-1.1.3.tgz",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
@ -999,7 +954,7 @@
},
"commander": {
"version": "2.20.0",
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.20.0.tgz",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"dev": true
},
@ -1265,7 +1220,7 @@
},
"esutils": {
"version": "2.0.2",
"resolved": "https://verdaccio.lossless.one/esutils/-/esutils-2.0.2.tgz",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
"dev": true
},
@ -1530,23 +1485,6 @@
"har-schema": "^2.0.0"
}
},
"has-ansi": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/has-ansi/-/has-ansi-2.0.0.tgz",
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=",
"dev": true,
"requires": {
"ansi-regex": "^2.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://verdaccio.lossless.one/ansi-regex/-/ansi-regex-2.1.1.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
"dev": true
}
}
},
"has-binary2": {
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/has-binary2/-/has-binary2-1.0.3.tgz",
@ -1569,7 +1507,7 @@
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://verdaccio.lossless.one/has-flag/-/has-flag-3.0.0.tgz",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
@ -1752,9 +1690,9 @@
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"js-tokens": {
"version": "3.0.2",
"resolved": "https://verdaccio.lossless.one/js-tokens/-/js-tokens-3.0.2.tgz",
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=",
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
},
"js-yaml": {
@ -2008,7 +1946,7 @@
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://verdaccio.lossless.one/mkdirp/-/mkdirp-0.5.1.tgz",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
@ -2017,7 +1955,7 @@
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://verdaccio.lossless.one/minimist/-/minimist-0.0.8.tgz",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
}
@ -2207,7 +2145,7 @@
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://verdaccio.lossless.one/path-parse/-/path-parse-1.0.6.tgz",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
@ -2377,7 +2315,7 @@
},
"resolve": {
"version": "1.10.0",
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.10.0.tgz",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz",
"integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
"dev": true,
"requires": {
@ -2700,10 +2638,13 @@
"dev": true
},
"supports-color": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/supports-color/-/supports-color-2.0.0.tgz",
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
},
"symbol-tree": {
"version": "3.2.2",
@ -2758,12 +2699,12 @@
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
},
"tslint": {
"version": "5.15.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.15.0.tgz",
"integrity": "sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==",
"version": "5.16.0",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.16.0.tgz",
"integrity": "sha512-UxG2yNxJ5pgGwmMzPMYh/CCnCnh0HfPgtlVRDs1ykZklufFBL1ZoTlWFRz2NQjcoEiDoRp+JyT0lhBbbH/obyA==",
"dev": true,
"requires": {
"babel-code-frame": "^6.22.0",
"@babel/code-frame": "^7.0.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
@ -2786,7 +2727,7 @@
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://verdaccio.lossless.one/tsutils/-/tsutils-2.29.0.tgz",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {

View File

@ -16,8 +16,8 @@
"@gitzone/tsbuild": "^2.1.8",
"@gitzone/tstest": "^1.0.20",
"@pushrocks/tapbundle": "^3.0.9",
"@types/node": "^11.13.4",
"tslint": "^5.15.0",
"@types/node": "^11.13.6",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0"
},
"peerDependencies": {
@ -30,10 +30,10 @@
"@pushrocks/smartfile": "^7.0.2",
"@pushrocks/smarthash": "^2.0.4",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.14",
"@pushrocks/smartrequest": "^1.1.15",
"@pushrocks/smartrx": "^2.0.3",
"@pushrocks/smartsocket": "^1.1.27",
"@pushrocks/smarttime": "^3.0.7",
"@pushrocks/smartunique": "^3.0.1"
}
}
}

View File

@ -1,16 +1,13 @@
# @pushrocks/smartuniverse
messaging service for micro services
## Availabililty and Links
- [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartuniverse)
- [gitlab.com (source)](https://gitlab.com/pushrocks/smartuniverse)
- [github.com (source mirror)](https://github.com/pushrocks/smartuniverse)
- [docs (typedoc)](https://pushrocks.gitlab.io/smartuniverse/)
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartuniverse)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartuniverse)
* [github.com (source mirror)](https://github.com/pushrocks/smartuniverse)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartuniverse/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartuniverse/badges/master/build.svg)](https://gitlab.com/pushrocks/smartuniverse/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartuniverse/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartuniverse/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartuniverse.svg)](https://www.npmjs.com/package/@pushrocks/smartuniverse)
@ -28,6 +25,7 @@ Use TypeScript for best in class instellisense.
Think WhatsApp, but for your microservices architecture. It allows your services to securely talk to each other in **private, shielded channels** without having to expose anything to the outside world. This allows the use of **reactive programming across your entire stack**.
### Server side
every universe has a server that manages messages.
Think Kafka, but without Kafka.
@ -46,11 +44,12 @@ myUniverse.start(8765); // start the server and provide the port on which to lis
```
### Client side
All your microservices represents clients in the universe that may talk to each other using the universe server.
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)
| 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)

View File

@ -32,17 +32,11 @@ tap.test('create smartuniverse client', async () => {
});
tap.test('should add a channel to the universe', async () => {
await testUniverse.addChannel(
testChannelData.channelName,
testChannelData.channelPass
);
await testUniverse.addChannel(testChannelData.channelName, testChannelData.channelPass);
});
tap.test('should add the same channel to the client universe in the same way', async () => {
await testClientUniverse.addChannel(
testChannelData.channelName,
testChannelData.channelPass
);
await testClientUniverse.addChannel(testChannelData.channelName, testChannelData.channelPass);
});
tap.test('should get a observable correctly', async () => {

View File

@ -12,4 +12,4 @@ export interface IServerPutMessageRequestBody {
passphrase: string;
message: string;
payload: any;
}
}

View File

@ -7,10 +7,7 @@ import * as url from 'url';
import * as interfaces from './interfaces';
import {
ClientUniverseChannel,
UniverseMessage
} from './';
import { ClientUniverseChannel, UniverseMessage } from './';
export interface IClientOptions {
serverAddress: string;
@ -35,47 +32,46 @@ export class ClientUniverse {
* adds a channel to the channelcache
* TODO: verify channel before adding it to the channel cache
*/
public async addChannel (channelNameArg: string, passphraseArg: string) {
const existingChannel = this.getChannel(channelNameArg);
public async addChannel(channelNameArg: string, passphraseArg: string) {
const existingChannel = await this.getChannel(channelNameArg);
if (existingChannel) {
throw new Error('channel exists');
}
// lets create the channel
ClientUniverseChannel.createClientUniverseChannel(
this,
channelNameArg,
passphraseArg
);
ClientUniverseChannel.createClientUniverseChannel(this, channelNameArg, passphraseArg);
}
/**
* gets a channel from the channelcache
* @param channelName
* @param passphraseArg
* @param passphraseArg
*/
public async getChannel(channelName: string): Promise<ClientUniverseChannel> {
await this.checkConnection();
const clientUniverseChannel = this.channelCache.find(channel => {
return channel.name === channelName;
})
});
return clientUniverseChannel;
}
public async sendMessage(messageArg: interfaces.IMessageCreator) {
console.log('hello');
const requestBody: interfaces.IUniverseMessage = {
id: plugins.smartunique.shortId(),
timestamp: Date.now(),
passphrase: (await this.getChannel(messageArg.targetChannelName)).passphrase,
...messageArg,
...messageArg
};
const requestBodyString = JSON.stringify(requestBody);
// TODO: User websocket connection if available
const response = await plugins.smartrequest.postJson(`${this.options.serverAddress}/sendmessage` , {
requestBody: requestBodyString
});
const response = await plugins.smartrequest.postJson(
`${this.options.serverAddress}/sendmessage`,
{
requestBody: requestBodyString
}
);
}
public close() {

View File

@ -10,15 +10,19 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
/**
* creates a channel and adds it to the cache of clientUniverseArg
* @param clientUniverseArg
* @param channelNameArg
* @param passphraseArg
* @param channelNameArg
* @param passphraseArg
*/
public static async createClientUniverseChannel(
clientUniverseArg: ClientUniverse,
channelNameArg: string,
passphraseArg: string
): Promise<ClientUniverseChannel> {
const clientChannel = new ClientUniverseChannel(clientUniverseArg, channelNameArg, passphraseArg);
const clientChannel = new ClientUniverseChannel(
clientUniverseArg,
channelNameArg,
passphraseArg
);
clientUniverseArg.channelCache.add(clientChannel);
await clientChannel.subscribe();
return clientChannel;
@ -31,11 +35,11 @@ export class ClientUniverseChannel implements interfaces.IUniverseChannel {
// properties
public name: string;
public passphrase: string;
// refs
public clientUniverse: ClientUniverse;
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
constructor(clientUniverseArg: ClientUniverse, nameArg: string, passphraseArg: string) {
this.clientUniverse = clientUniverseArg;
this.name = nameArg;
this.passphrase = passphraseArg;

View File

@ -6,9 +6,7 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
// ======
// STATIC
// ======
public static createMessageFromPayload(messageDescriptor: interfaces.IUniverseMessage) {
};
public static createMessageFromPayload(messageDescriptor: interfaces.IUniverseMessage) {}
// ========
// INSTANCE
@ -26,7 +24,5 @@ export class ClientUniverseMessage implements interfaces.IUniverseMessage {
public targetChannelName: string;
constructor(messageArg, payloadArg) {}
getAsJsonForPayload () {
}
getAsJsonForPayload() {}
}

View File

@ -11,8 +11,6 @@ export interface ISmartUniverseConstructorOptions {
messageExpiryInMilliseconds: number;
}
/**
* main class that setsup a Universe
*/
@ -67,7 +65,7 @@ export class Universe {
/**
* initiates a server
*/
public async start(portArg: number | string) {
public async start(portArg: number) {
// lets create the base smartexpress server
this.smartexpressServer = new plugins.smartexpress.Server({
cors: true,
@ -79,10 +77,15 @@ export class Universe {
});
// lets create the http request route
this.smartexpressServer.addRoute('/sendmessage', new Handler('POST', async (req, res) => {
const universeMessageInstance = new UniverseMessage(req.body);
this.universeCache.addMessage(universeMessageInstance);
}));
this.smartexpressServer.addRoute(
'/sendmessage',
new Handler('POST', async (req, res) => {
const universeMessageInstance = new UniverseMessage(req.body);
this.universeCache.addMessage(universeMessageInstance);
res.status(200);
res.end();
})
);
// add websocket upgrade
this.smartsocket = new plugins.smartsocket.Smartsocket({

View File

@ -14,7 +14,6 @@ import { IUniverseMessage } from './interfaces';
* acts as a container to save message states like authentication status
*/
export class UniverseMessage implements interfaces.IUniverseMessage {
public id: string;
public timestamp: number;
@ -40,7 +39,7 @@ export class UniverseMessage implements interfaces.IUniverseMessage {
* wether the message is authenticated
*/
public authenticated: boolean = null;
/**
* a destruction timer for this message
*/