Skip to content

Commit

Permalink
feat: socketio extension improvements (#1)
Browse files Browse the repository at this point in the history
- add files of websocket extension implementation
- bind key for request listener used to create httpserver
- bind SocketIO instance and created namespaces
- add providers ot handler sequence of event handle
- preparing socket controller factory for test
- add booter to autoload controller
- preparation context connection moved into websocket controller factory
- add decorator for injection of io server as param
- separate httpOptions of serverOptions in the applications options
- add socketio controller booter
- test(socketio): add unit test from webscoket extension
- move application and controllers into acceptance tests to fixture dir
- add acceptance tests for events
- remove unnecessaries packages
- add constant SocketIOBinding.CONTROLLERS_NAMASPACE
- license update
- update MONOREPO and CODEOWNERS
- remove websocket extension
- update imports and options

Signed-off-by: Alexander Rondón <[email protected]>
Signed-off-by: mayank <[email protected]>
  • Loading branch information
alexkander committed Oct 17, 2020
1 parent 661303c commit 3fe2609
Show file tree
Hide file tree
Showing 47 changed files with 6,759 additions and 467 deletions.
1 change: 1 addition & 0 deletions docs/site/MONOREPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ one in the monorepo: `npm run update-monorepo-file`
| [examples/rest-crud](https://github.com/strongloop/loopback-next/tree/master/examples/rest-crud) | @loopback/example-rest-crud | An example showing how to use @loopback/rest-crud to define default repository and controller classes |
| [examples/rpc-server](https://github.com/strongloop/loopback-next/tree/master/examples/rpc-server) | @loopback/example-rpc-server | An example RPC server and application to demonstrate the creation of your own custom server |
| [examples/soap-calculator](https://github.com/strongloop/loopback-next/tree/master/examples/soap-calculator) | @loopback/example-soap-calculator | A tutorial demonstrating integration SOAP webservice with LoopBack 4 |
| [examples/socketio](https://github.com/strongloop/loopback-next/tree/master/examples/socketio) | @loopback/example-socketio | This is an example for spinning up socket server. |
| [examples/todo](https://github.com/strongloop/loopback-next/tree/master/examples/todo) | @loopback/example-todo | Tutorial example on how to build an application with LoopBack 4 |
| [examples/todo-jwt](https://github.com/strongloop/loopback-next/tree/master/examples/todo-jwt) | @loopback/example-todo-jwt | A modified Todo tutorial how to build an application with JWT authentication and LoopBack 4 |
| [examples/todo-list](https://github.com/strongloop/loopback-next/tree/master/examples/todo-list) | @loopback/example-todo-list | Continuation of the todo example using relations in LoopBack 4. |
Expand Down
4 changes: 2 additions & 2 deletions examples/socketio/DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ users.

Install the following extensions:

- [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

## Development workflow

Expand Down
4 changes: 3 additions & 1 deletion examples/socketio/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# socketio

This application is generated using [LoopBack 4 CLI](https://loopback.io/doc/en/lb4/Command-line-interface.html) with the
This application is generated using
[LoopBack 4 CLI](https://loopback.io/doc/en/lb4/Command-line-interface.html)
with the
[initial project layout](https://loopback.io/doc/en/lb4/Loopback-application-layout.html).

## Install dependencies
Expand Down
16 changes: 9 additions & 7 deletions examples/socketio/src/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ import {BootMixin} from '@loopback/boot';
import {ApplicationConfig} from '@loopback/core';
import {RepositoryMixin} from '@loopback/repository';
import {ServiceMixin} from '@loopback/service-proxy';
import {SocketApplication, SocketIOServer} from '@loopback/socketio';
import {SocketIOApplication, SocketIOServer} from '@loopback/socketio';
import debugFactory from 'debug';
import {SocketIOController} from './controllers';

const debug = debugFactory('loopback:example:socketio:demo');

export {ApplicationConfig};

export class SocketioApplication extends BootMixin(
ServiceMixin(RepositoryMixin(SocketApplication)),
export class SocketIOExampleApplication extends BootMixin(
ServiceMixin(RepositoryMixin(SocketIOApplication)),
) {
readonly ioServer: SocketIOServer;

constructor(options: ApplicationConfig = {}) {
options.httpServerOptions = options.httpServerOptions || {};
options.httpServerOptions.port = +(process.env.PORT || 3001);
options.httpServerOptions.host = process.env.HOST || '127.0.0.1';
options.httpServerOptions.url = process.env.URL || '127.0.0.1:3001';
options.socketio = options.socketio || {};
options.socketio.http = options.socketio.http || {};
options.socketio.server = options.socketio.server || {};
options.socketio.http.port = +(process.env.PORT ?? 3001);
options.socketio.http.host = process.env.HOST ?? '127.0.0.1';
options.socketio.http.url = process.env.URL ?? '127.0.0.1:3001';
super(options);

this.projectRoot = __dirname;
Expand Down
12 changes: 7 additions & 5 deletions examples/socketio/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {ApplicationConfig, SocketioApplication} from './application';
import {ApplicationConfig, SocketIOExampleApplication} from './application';

export * from './application';

export async function main(options: ApplicationConfig = {}) {
const app = new SocketioApplication(
const app = new SocketIOExampleApplication(
options || {
httpServerOptions: {
host: '127.0.0.1',
port: 3001,
socketio: {
http: {
host: '127.0.0.1',
port: 3001,
},
},
},
);
Expand Down
4 changes: 2 additions & 2 deletions examples/socketio/src/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {SocketioApplication} from './application';
import {SocketIOExampleApplication} from './application';

export async function migrate(args: string[]) {
const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter';
console.log('Migrating schemas (%s existing schema)', existingSchema);

const app = new SocketioApplication();
const app = new SocketIOExampleApplication();
await app.boot();
await app.migrateSchema({existingSchema});

Expand Down
31 changes: 29 additions & 2 deletions examples/socketio/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,34 @@
"extends": "@loopback/build/config/tsconfig.common.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
"rootDir": "src",
"composite": true
},
"include": ["src"]
"include": [
"src/**/*",
"src/**/*.json"
],
"references": [
{
"path": "../../extensions/socketio/tsconfig.json"
},
{
"path": "../../packages/boot/tsconfig.json"
},
{
"path": "../../packages/core/tsconfig.json"
},
{
"path": "../../packages/repository/tsconfig.json"
},
{
"path": "../../packages/rest-explorer/tsconfig.json"
},
{
"path": "../../packages/service-proxy/tsconfig.json"
},
{
"path": "../../packages/testlab/tsconfig.json"
}
]
}
4 changes: 2 additions & 2 deletions extensions/socketio/LICENSE
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Copyright (c) IBM Corp. 2020.
Copyright (c) IBM Corp. 2019,2020.
Node module: @loopback/socketio
This project is licensed under the MIT License, full text below.

--------

MIT License

MIT License Copyright (c) IBM Corp. 2020
MIT License Copyright (c) IBM Corp. 2019,2020

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
Expand Down
Loading

0 comments on commit 3fe2609

Please sign in to comment.