Registry / http-networking / cryo-server

cryo-server

JSON →
library2.9.4jsnpmunverified

Cryo-Server is a lightweight WebSocket server framework for Node.js that handles client authentication, session lifecycle management, and data framing. Current stable version is 2.9.4. Part of the Cryo ecosystem with client implementations for TypeScript/JavaScript (Node.js and browsers) and C# (.NET). Key differentiators: built-in backpressure support with configurable drop policies, SSL/TLS support, and an extension interface for building RPC or other protocols on top. Released on npm, with infrequent updates.

npm install cryo-server
INSTALL
IMPORT
SIG · CRYO-SERVER
C
cryo-server
http-networkingjavascriptv2.9.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cryo
✓ import { cryo } from 'cryo-server'
✗ const cryo = require('cryo-server')
cryo is a named export, not default. Package is ESM-only since v2.
ITokenValidator
✓ import type { ITokenValidator } from 'cryo-server'
✗ import { ITokenValidator } from 'cryo-server'
Type-only import for TypeScript users. ITokenValidator is a TypeScript interface, not a value.
ICryoWebsocketServerOptions
✓ import type { ICryoWebsocketServerOptions } from 'cryo-server'
✗ import { ICryoWebsocketServerOptions } from 'cryo-server'
Type-only import for TypeScript users.

Initializes a Cryo server with token validation, event listeners for session lifecycle, and backpressure configuration.

import { cryo } from 'cryo-server'; const tokenValidator = { validate: async (token: string): Promise<boolean> => { // Simple example: accept tokens that are not empty return token.length > 0; } }; const options = { port: 8080, keepAliveIntervalMs: 15000, backpressure: { highWaterMark: 16 * 1024 * 1024, lowWaterMark: 1024 * 1024, maxQueuedBytes: 8 * 1024 * 1024, maxQueueCount: 1024, dropPolicy: "drop-oldest" } }; const server = cryo(tokenValidator, options); server.on('session:open', (session) => { console.log('Session opened:', session.id); session.send('Welcome!'); }); server.on('session:message', (session, data) => { console.log('Received:', data); session.send('Echo: ' + data); }); server.on('session:close', (session) => { console.log('Session closed:', session.id); });
Debug
Known issues
breakingIn v2.0.0, the package switched to ESM-only. Using require() throws an error.
fix
Use import { ... } from 'cryo-server' and ensure package.json includes "type": "module".
affects: >=2.0.0
breakingIn v2.0.0, the cryo function signature changed: the port option moved from a separate parameter to inside the options object.
fix
Pass port inside the options object: cryo(validator, { port: 8080 }) instead of cryo(port, validator).
affects: >=2.0.0 <2.0.0?
gotchaIf no backpressure configuration is provided, default values are used which may not suit high-load scenarios.
fix
Explicitly configure backpressure options based on your expected load.
affects: >=1.0.0
gotchaThe validate function in ITokenValidator must return a boolean. Returning undefined or null will be treated as false.
fix
Always return true or false explicitly.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/cryo-server/dist/index.js from /path/to/app.js not supported.
Using CommonJS require() with an ESM-only package.
fix
Switch to import syntax or set "type": "module" in your package.json.
TypeError: cryo is not a function
Importing the default export instead of the named export cryo.
fix
Use import { cryo } from 'cryo-server' instead of import cryo from 'cryo-server'.
TypeError: Cannot read properties of undefined (reading 'validate')
Passing an empty object instead of an ITokenValidator as the first argument.
fix
Provide a valid token validator object with a validate method.
Upgrade
Version history
2.9.4latest on npm
Audit
Dependencies
wsoptionalWebSocket library used under the hood for actual WebSocket connections
bufferoptionalUsed for Buffer manipulation, but Node.js built-in; not a real dependency
Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
1
Resources
cryo-server — npm install cryo-server · libregistry