1.1.13 • Published 6 years ago

hee v1.1.13

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

(H)ttp (E)vent (E)mitter

(H)ttp (E)vent (E)mitter

Installing

npm i hee

Example

Client (client.html)

<!DOCTYPE html>
<html>

<body>
    <script type="text/javascript">
        var source = new EventSource("http://localhost:8080/");
        source.onmessage = function (e) {
            document.body.innerHTML += `${e.data} <br>`;
        };
    </script>
</body>

</html>

Server (server.mjs)

import HttpEventEmitter from 'hee'

const hee = new HttpEventEmitter(8080)

hee.on('subscription', (params) => {
  console.log('New subscription', params)
})

hee.on('event', (params) => {
  console.log('New event', params)
})

Run

node --experimental-modules server.mjs

Hee is using experimental ECMAScript modules https://nodejs.org/api/esm.html

API

const hee = new HttpEventEmitter([PORT])

Events

hee.on("subscription", params)

Emitted when a new client GET a path to listen.

hee.on("event", params)

Emitted when a client POST to a path.

Params:

{ 
  path: '/namespace/id/1',
  id: 'ad5a71fc-abc7-4d92-a585-d56934047ce9',
  data: { payload: 'Hello World' } 
}
1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.1

6 years ago

1.0.21

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago