ws13 โ€” WebSocket API v1.1.0

Modular, extensible and operations-friendly WebSocket framework for Node.js. This release focuses on a small, stable core so dependent projects can proceed; extensions (channels, auth, history, events, admin, routing, heartbeat, message-meta, permessage-deflate) exist as planned work and will be completed and documented in follow-up releases.

Status: core stable and testable โ€” extensions work in progress (APIs present in repository; integration examples available in examples/).

๐Ÿ“š Table of Contents


โœจ Highlights (v1.1.0)

Extensions (channels, events, history, admin, routing, message-meta, heartbeat) are available as separate modules in the repo but marked WIP โ€” README below points to that.

Back to top โ†‘


๐Ÿ“ฆ Installation

npm:

npm install ws13

yarn:

yarn add ws13

Back to top โ†‘


๐Ÿš€ Quick start โ€” minimal server

This example uses the core createWebSocket exported from the package.

const http = require('http');
const createWebSocket = require('ws13');

const server = http.createServer();

const { registry } = createWebSocket.attachServer(server, {
  onConnect(ws, req) {
    ws.send('Welcome');
    ws.on('message', (evt) => {
      // simple echo
      ws.send(`Echo: ${evt.data}`);
    });
  }
});

server.listen(8080);

Client (Node.js reusing createWebSocket in client mode):

const http = require('http');
const createWebSocket = require('ws13');

const req = http.request({ host: '127.0.0.1', port: 8080, path: '/' });
const ws = createWebSocket({ request: req });

ws.on('open', () => ws.send('hello'));
ws.on('message', (evt) => console.log(evt.data));

Browser clients should use the native WebSocket API (wss:// for TLS).

Back to top โ†‘


๐Ÿงฉ Core API (summary)

TypeScript definitions are available at 'index.d.ts' for full shapes and options.

Back to top โ†‘


๐Ÿงช Tests

Project ships basic tests for the core. Use test-runner-lite (or Node directly) to run tests.

Run all tests:

npm test

Run the core test directly:

node ./index.test.js

Example core tests included:

Add more tests as needed; tests live next to core and in each extension folder when implemented.

Back to top โ†‘


๐Ÿงฉ Extension roadmap (short)

The following extensions exist as separate modules and will be fully documented and stabilised in subsequent releases. Current status: prototype/partial implementations present in repo.

If your project relies on a specific extension, tell me which one and I will prioritise finishing it and publishing a stable interface.

Back to top โ†‘


๐Ÿ›  Operational notes

Back to top โ†‘


๐Ÿ“ Project Structure

ws13/
    core/
        index.d.ts
        index.js
        index.test.js
        permessage-deflate.js
        README.md
    extensions/
        admin/
            index.d.ts
            index.js
            index.test.js
            README.md
            express-middleware.d.ts
            express-middleware.js
            examples/
                admin-api/
                    server.js
                admin-dashboard/
                    admin-dashboard.html
                admin-express-integration/
                    index.js
                    README.md
        auth/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                auth-channels-client.js
                auth-channels-server.js
                server-with-admin.js
        channels/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                channels/
                    client.js
                    server.js
        events/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                events/
                    client.js
                    server.js
        heartbeat/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                heartbeat/
                    client.js
        history/
            index.d.ts
            index.js
            index.test.js
            README.md
            sqlite-adapter.js
            sqlite-adapter.test.js
            examples/
                history/
                    client.js
                    server.js
        message-meta/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                message-meta/
                    client.js
                    server.js
                    routing-server.js
        routing/
            index.d.ts
            index.js
            index.test.js
            README.md
            examples/
                routing/
                    client.js
                    server.js
    logo/
        logo-ws13.png
    browser.js
    index.d.ts
    index.js
    LICENSE
    package.json
    README.md
    testRunner.js
    wrapper.mjs

Back to top โ†‘


๐Ÿ“Œ Contributing & development

Back to top โ†‘


๐Ÿ“œ License

This project is licensed under the MIT License.
Copyright ยฉ Manuel Lรตhmus

Back to top โ†‘