Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

configurapi-handler-ws

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configurapi-handler-ws

Configurapi request handlers for websocket

Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
25
-93.21%
Maintainers
1
Weekly downloads
 
Created
Source

configurapi-handler-ws

Configurapi request handlers for websocket

Usage

Server side:

  • If you want to stream data back to the client, return a StreamResponse with a readable stream.
  • Use pushbackFunction(postbackFunction: Function, response: PostbackResponse) to send a response to the postback endpoint. The response will be wrapped in the specified postbackFunction.
const { pushbackFunction, PostbackResponse } = require("configurapi-handler-ws");

let callback = async (body:any, headers:Record<string,string>) => 
      {
          const isStream = body && typeof body === 'object' && typeof body.pipe === 'function';
          const isBinary = typeof body === 'string' || Buffer.isBuffer(body) || body instanceof Uint8Array;

          let resp = await fetch(`http://localhost:9100/@connections/${connectionId}`, {
              method: 'POST',
              headers,
              body: isStream || isBinary ? body : JSON.stringify(body),
              ...(isStream ? { duplex: 'half' } : {})
          });

          console.log(resp.status + ' ' + resp.statusText)
          console.log(await resp.json())
      }

  await pushbackFunction(callback, new PostbackResponse('body', {'content-type': 'application/json'}))

Client side:

  • Use WebSocketClient to connect to a WebSocket runner, send data over the connection, and disconnect from the runner when finished.
  • To pass data (such as a protocol or authentication token) when establishing the WebSocket connection, provide it as the second parameter to the constructor.
const { WebSocketClient } = require("configurapi-handler-ws");
let client = new WebSocketClient(WEBSOCKET_BASE_URL, {onPush: (data:IResponse)=>console.log(data)});

Keywords

configurapi

FAQs

Package last updated on 13 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts