npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

maeva-sockets

v3.0.16

Published

maeva-sockets ===

Downloads

77

Readme

maeva-sockets

Client/server web sockets API to connect any database via maeva

Why

Even when you have a database server set up, you need a relay server (HTTP or Web Sockets) so that your client can connect to the database server. maeva-sockets gives a framework so you can easily create a server your client can talk to to transport database queries.

Server

It is easy to set up a server. Let's say you want to set up a server that can transport queries to a MongoDB server:

import sockets from 'maeva-sockets/server';
import mongodb from 'maeva-mongodb';

const WS_URL = 'ws://localhost:9999'; // Web sockets server URL
const DB_URL = 'mongodb://localhost:7777'; // Database URL

sockets
  .start(WS_URL, {connector: () => mongodb(DB_URL, {keepAlive: 5000})})
  .on('error', error => console.log(error));

Client

import * as data from 'maeva';
import sockets from 'maeva-sockets/client';

// Define your data model
const userModel = data.model('users', {name: String});

// Connect to sockets server
data.connect(sockets('ws://localhost:9999', {keepAlive: 3000}));

// Now you can call any queries
const users = await data.findMany(userModel);

Server methods

sockets.start(url: string, options: ServerOptions) => EventEmitter
sockets.start(options: ServerOptions) => EventEmitter

// Close server
const server = sockets.start('ws://localhost:9999');
server.emit('close');

// Off helper
server.off('event', fn) === server.removeListener('event', fn);

Server options

  • port: number
  • host: string
  • path: string

Server events

  • closed Web sockets server down
  • connected Web sockets server successfully connected to database
  • disconnected Web sockets server lost connection to database
  • error Web sockets server had an error
  • incoming New web socket client
  • listening Web sockets server started
  • outcoming Web socket sent a message to client
  • response Web socket server got response from DB

Client

sockets(url: string, options: ClientOptions);

Client options

  • debug: boolean
  • keepAlive: number

When the sockets server is up, but the connection to database is down, client will receive an error that has code DISCONNECTED_FROM_DB.

const client = data.connect(sockets('ws://localhost:8080'));
client.emitter.on('error', (error) => {
  if (error.code === 'DISCONNECTED_FROM_DB') {
    console.log('server lost connection to db');
  }
})