1.2.0 • Published 2 years ago

@h0rn0chse/socket-server v1.2.0

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

socket-server

Extends express.js and ws server with some utilities

Getting Started

This project is available as npm package.

Installation

npm i @h0rn0chse/socket-server

Basic Usage

import { registerSocketHandler, registerXhrHandler, send, startServer } from "@h0rn0chse/socket-server";

startServer({
    host: "localhost",
    port: 3000
})

registerXhrHandler("get", "/data/blob", (req, res, token) => {
    res.json({ foo: "bar" })
    res.end();
});

registerSocketHandler("ping", (ws, data, uuid) => {
    send(ws, "pong", { foo: "bar" });
});

For more examples see the documentation and the demo files:

Limitations

This module can only be used with esm modules.

// package.json
{
    "type": "module"
}

Libraries

1.2.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago