Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

@furystack/websocket-api

Package Overview
Dependencies
7
Maintainers
1
Versions
158
Issues
File Explorer

Advanced tools

@furystack/websocket-api

HTTP Api FuryStack package

    8.0.4latest

Version published
Maintainers
1
Yearly downloads
9,268
decreased by-8.22%

Weekly downloads

Readme

Source

websocket-api

WebSocket implementation for FuryStack

Usage example

You can initialize the WebSocket package in the following way

const myInjector = new Injector() .useWebsockets({ path: '/api/sockets', actions: [WhoAmI], })

Implement your own actions

You can implement a WebSocket action in the following way:

import { User } from '@furystack/core' import { HttpUserContext } from '@furystack/http-api' import { Injectable } from '@furystack/inject' import { Data } from 'ws' import * as ws from 'ws' import { IWebSocketAction } from '../models/IWebSocketAction' @Injectable({ lifetime: 'transient' }) export class WhoAmI implements WebSocketAction { public dispose() { /** */ } public static canExecute(data: Data): boolean { return data.toString() === 'whoami' || data.toString() === 'whoami /claims' } public async execute() { const currentUser = await this.httpUserContext.getCurrentUser() this.websocket.send(JSON.stringify(currentUser)) } constructor(private httpUserContext: HttpUserContext<User>, private websocket: ws) {} }

Keywords

FAQs

What is @furystack&#x2F;websocket-api?

HTTP Api FuryStack package

Is @furystack&#x2F;websocket-api popular?

The npm package @furystack&#x2F;websocket-api receives a total of 5 weekly downloads. As such, @furystack&#x2F;websocket-api popularity was classified as not popular.

Is @furystack&#x2F;websocket-api well maintained?

We found that @furystack&#x2F;websocket-api demonstrated a healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.

Last updated on 16 May 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc