0.0.15 • Published 4 years ago

@bitbeat/websocket v0.0.15

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

BITBEAT WEBSOCKET MODULE

Introduction

This is the official websocket module for bitbeat using ws. This package will export you a websocket server and a websocket server config. To use it follow the documentation of bitbeat at the homepage.

Configure

The default WebConfig looks like this:

export default class WebSocketServerConfig extends Configuration {
    constructor() {
        super();
    }

    default: {
        host: string;
        port: number;
        [name: string]: any;
    } = {
        host: 'localhost',
        port: 5000,
        perMessageDeflate: {
            zlibDeflateOptions: {
                chunkSize: 1024,
                memLevel: 7,
                level: 3,
            },
            zlibInflateOptions: {
                chunkSize: 10 * 1024,
            },
            clientNoContextTakeover: true,
            serverNoContextTakeover: true,
            serverMaxWindowBits: 10,
            concurrencyLimit: 10,
            threshold: 1024,
        },
    };
}

You can edit those properties by either extending the WebSocketConfig class in your project's config folder as own class or edit it in the boot.js.

Example 1:

-- config  |-- myOwnConfig.ts

import { WebSocketConfig } from '@bitbeat/websocket';
import { merge } from 'lodash';

export default class MyOwnConfig extends WebSocketConfig {
    constructor() {
        super();
    }

    default = {}; // this will overwrite the default props

    /* or you can do something non-destructive like this
    default = merge(default, {
        port: 3000,
    });
    */
}

Example 2:

This example happens in the boot.js:

import { registerBulk } from '@bitbeat/core';
import { WebSocketConfig, WebSocketServer } from '@bitbeat/websocket';

export default async () => {
    const webSocketConfig = new WebSocketConfig();
    webSocketConfig.default.port = 3000;
    await registerBulk(new Set([webSocketConfig, WebSocketServer]));
};
0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago