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

rvms-backend

v0.1.5

Published

RVMS (Video-MS) Node.js backend integration — auth, alarm WS, stream proxy

Readme

rvms-backend

Express middleware that proxies RVMS (Video-MS) — handles JWT auth, streams video, and relays alarms to your frontend without exposing credentials.

Install

npm install rvms-backend

Usage

import express from 'express';
import http from 'http';
import { createRvmsRouter } from 'rvms-backend';

const app = express();
const server = http.createServer(app);

const { router, handleUpgrade } = await createRvmsRouter({
  rvmsUrl: 'http://192.168.1.100:4000',
  username: 'admin',
  password: 'admin123',
  onAlarm: (event) => console.log('alarm', event.type),
});

app.use('/api', router);
server.on('upgrade', handleUpgrade);
server.listen(3000);

When a frontend connects to /ws/stream?nvrId=...&deviceId=..., the backend opens a WebSocket to RVMS with the JWT token and pipes the fMP4 video back. The frontend never touches the RVMS URL or the token.

Authentication

These routes are unauthenticated by default. Protect them with your own Express middleware:

import express from 'express';
import { createRvmsRouter } from 'rvms-backend';

const app = express();

function requireAuth(req, res, next) {
  const token = req.headers.authorization?.split(' ')[1];
  if (!token || !validateYourToken(token)) {
    return res.status(401).json({ error: 'unauthorized' });
  }
  next();
}

const { router } = await createRvmsRouter({
  rvmsUrl: 'http://localhost:4000',
  username: 'admin',
  password: 'secret',
});

// Mount behind your auth middleware
app.use('/api', requireAuth, router);

For WebSocket endpoints, pass the token as a query parameter from the frontend:

// Frontend (rvms-vue components)
<RvmsVideoPlayer token="your-jwt-token" ... />

// Backend reads it from the URL
// The token is passed as ?token=... in WS URLs

API

createRvmsRouter(options)

| Option | Type | Description | |--------|------|-------------| | rvmsUrl | string | RVMS backend URL (e.g. http://localhost:4000) | | username | string | RVMS login username | | password | string | RVMS login password | | onAlarm | (event) => void | Optional callback for received alarms |

Returns { router, handleUpgrade, auth, api, alarmClient }.

Proxied endpoints

| Endpoint | Method | Description | |----------|--------|-------------| | /api/nvrs | GET | List NVRs | | /api/nvrs/:id/devices | GET | List cameras | | /api/playback/search | GET | Search recordings | | /api/alarms/recent | GET | Recent alarms | | /api/alarms/snapshots/:id | GET | Snapshot image (proxied with auth) | | /ws/stream?nvrId&deviceId&mode&profile | WS | Video stream (proxied to RVMS) | | /ws/alarms | WS | Real-time alarm events |

RvmsAuthManager

const auth = new RvmsAuthManager('http://localhost:4000');
await auth.login('admin', 'password');
auth.getAccessToken(); // current JWT

RvmsApiClient

const api = new RvmsApiClient('http://localhost:4000', auth);
await api.listNvrs();
await api.listDevices(nvrId);
await api.searchPlayback(nvrId, deviceId, from, to);
await api.recentAlarms();
api.buildStreamWsUrl(wsBase, nvrId, deviceId, { mode, profile });

RvmsAlarmClient

const alarms = new RvmsAlarmClient(auth, 'ws://localhost:4000');
alarms.onAlarmEvent((event) => console.log(event));
alarms.onInitialSnapshot((events) => console.log('snapshot', events.length));
alarms.onConnectionStatus((connected) => console.log(connected));
alarms.connect();

Full example

This package IS the example — browse src/index.ts for the complete implementation. For a ready-to-run demo with a Vue 3 frontend, see the rvms-vue package:

npm install rvms-vue

The full example frontend (with RvmsVideoPlayer, RvmsVideo, demo pages) is included in rvms-vue/src/.