Skip to content
This repository has been archived by the owner on Mar 13, 2020. It is now read-only.

[experimental] add integration with socket.io #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ packages/repository/* @raymondfeng
packages/repository-json-schema/* @bajtos
packages/rest/* @bajtos @raymondfeng
packages/service-proxy/* @raymondfeng
packages/socketio/* @raymondfeng
packages/testlab/* @bajtos
examples/todo/* @bajtos @hacksparrow
examples/express-composition/* @nabdelgadir
Expand Down
1 change: 1 addition & 0 deletions docs/apidocs.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h3>List of packages</h3>
<li><a href="./repository-json-schema.html">@loopback/repository-json-schema</a></li>
<li><a href="./rest.html">@loopback/rest</a></li>
<li><a href="./service-proxy.html">@loopback/service-proxy</a></li>
<li><a href="./socketio.html">@loopback/socketio</a></li>
<li><a href="./testlab.html">@loopback/testlab</a></li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/site/MONOREPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ The [loopback-next](https://github.com/strongloop/loopback-next) repository uses
| [repository](https://github.com/strongloop/loopback-next/tree/master/packages/repository) | @loopback/repository | Define and implement a common set of interfaces for interacting with databases |
| [rest](https://github.com/strongloop/loopback-next/tree/master/packages/rest) | @loopback/rest | Expose controllers as REST endpoints and route REST API requests to controller methods |
| [service-proxy](https://github.com/strongloop/loopback-next/tree/master/packages/service-proxy) | @loopback/service-proxy | A common set of interfaces for interacting with service oriented backends such as REST APIs, SOAP Web Services, and gRPC microservices |
| [socketio](https://github.com/strongloop/loopback-next/tree/master/packages/socketio) | @loopback/socketio | Expose controllers as Socket.IO endpoints |
| [testlab](https://github.com/strongloop/loopback-next/tree/master/packages/testlab) | @loopback/testlab | A collection of test utilities we use to write LoopBack tests |
| [tslint-config](https://github.com/strongloop/loopback-next/tree/master/packages/tslint-config) | @loopback/tslint-config | Shared TSLint config to enforce a consistent code style for LoopBack development |

Expand Down
25 changes: 25 additions & 0 deletions experimental/socketio/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2019. All Rights Reserved.
Node module: @loopback/socketio
This project is licensed under the MIT License, full text below.

--------

MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
66 changes: 66 additions & 0 deletions experimental/socketio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# @loopback/socketio

This module uses [socket.io](http://socket.io) to expose controllers as
WebSocket friendly endpoints.

## Use Cases

1. A real time application would like to use WebSocket friendly APIs to manage
subscriptions, participants (rooms) and message exchanges.

2. Make it easy for API developers to expose WebSocket friendly APIs without
learning a lot of low level concepts.

3. Use it as a step stone to explore messaging oriented API paradigms and
programming models, such as pub/sub, eventing, streaming, and reactive.

## High Level Design

The package will provide the following key constructs:

- SocketIOServer: A new server type that listens on incoming WebSocket
connections and dispatches messages to controllers that subscribe to the
namespace. Each server is attached to an http/https endpoint.

- SocketIO controller: A controller class that is decorated with SocketIO
related metadata, including:

- Map to a namespace
- Connect/disconnect events
- Subscribe/consume messages
- Publish/produce messages

- SocketIO middleware or sequence
- Allow common logic to intercept/process WebSocket messages

## Basic Use

1. Create a SocketIOServer
2. Define a controller to handle socket.io events/messages
3. Register the controller
4. Discover socket.io controllers and mount them to the SocketIOServer
namespaces.

## Installation

```sh
npm install --save @loopback/socketio
```

## Contributions

- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md)
- [Join the team](https://github.com/strongloop/loopback-next/issues/110)

## Tests

Run `npm test` from the root folder.

## Contributors

See
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors).

## License

MIT
7 changes: 7 additions & 0 deletions experimental/socketio/docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"content": [
"index.ts",
"src/**/*.ts"
],
"codeSectionDepth": 4
}
6 changes: 6 additions & 0 deletions experimental/socketio/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/socketio
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './dist';
6 changes: 6 additions & 0 deletions experimental/socketio/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/socketio
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

module.exports = require('./dist');
8 changes: 8 additions & 0 deletions experimental/socketio/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/socketio
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

// DO NOT EDIT THIS FILE
// Add any additional (re)exports to src/index.ts instead.
export * from './src';
Loading