Skip to content

WsPlugin

Danny SMc edited this page Nov 2, 2021 · 2 revisions

The WS (WebSocket) plugin is a built-in plugin that comes with a full flow for building WebSocket-based services. The plugin is built on top of Express, and provides a simple solution for building powerful APIs with little effort.

The WS service comes with a HTTP and WS service, decorators, interfaces and types, middleware and more. You can find an example of it's usage through this guide about controllers.


Features

  • A service for the express web server.
  • Express plugin called express-ws.
  • An action decorator for creating methods.
  • A middleware interface for authentication.
  • Context objects for accessing request data.

Usage

Below is an example of setting up the http plugin with the engine.

import { Engine, WsPlugin } from '@symbux/turbo';

const engine = new Engine({
	autowire: true,
});

engine.use(new WsPlugin({
	path: '/ws',
	port: 80,
}));

Options

Available options below.

Name Type Default Description
path string /ws The path the websocket will listen on.
port number null If the HttpPlugin is in use, then the WS server will attach to that, if not, it will require a port.
options Record<string, any> {} WS Options to pass to the underlying WS server.

Features

Plugins

Future Plans

Resources

Clone this wiki locally