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

@skweb/framework

v9.0.0

Published

Web/cron framework integrating database, redis, httpServer for skweb.

Readme

@skweb/framework

Base framework for skweb applications. Provides WebFramework, RealtimeFramework, and CronFramework singletons with unified lifecycle management, health checks, and graceful shutdown.

Installation

npm install @skweb/framework

WebFramework (HTTP)

import { WebFramework } from '@skweb/framework'
import { createExpressApp } from '@skweb/express'

const framework = new WebFramework({ runtimeFactory: createExpressApp })
framework.createApp()
await framework.setup({ modelsDir: './models', controllersDir: './controllers' })
framework.mountHealth()  // /healthz, /readyz, /startupz
framework.start(3000)

RealtimeFramework (WebSocket / Socket.IO)

Realtime server with declarative message handlers, ajv validation, middleware chain, and multi-node broadcast via Redis pub/sub.

import { RealtimeFramework, createRateLimitMiddleware } from '@skweb/framework'
import { createWsApp } from '@skweb/ws'

const rt = new RealtimeFramework({
  runtimeFactory: createWsApp,
  port: 3001,
  redis: redisInstance,           // optional: enables cross-node broadcast
  onConnect: (socket) => {        // optional: authentication hook
    const token = socket.handshake?.headers?.authorization
    if (!token) return false      // reject connection
    socket.data.set('userId', verifyJwt(token))
  }
})

rt.createApp()
await rt.setup({ handlersDir: './messages' })
rt.mountHealth()                   // health probes on port 3002
await rt.loadMessageHandlers()
rt.start()

Message Handlers

// messages/ping.ts
export default {
  type: 'ping',
  schema: { type: 'object', properties: { msg: { type: 'string' } } },
  middlewares: [createRateLimitMiddleware({ max: 20, windowMs: 10_000 })],
  async handle(ctx) {
    ctx.socket.send('pong', { echo: ctx.payload, timestamp: Date.now() })
  }
}

Key Features

  • Two modes: standalone (own port) or attached (share WebFramework's HTTP server)
  • Authentication: onConnect hook with socket.handshake (headers, query)
  • Rate limiting: createRateLimitMiddleware({ windowMs, max })
  • Health checks: mountHealth() -> /healthz, /readyz, /startupz
  • Multi-node broadcast: RedisBroadcaster (re-exported from @skweb/realtime) via @skweb/redis pub/sub
  • Targeted delivery: sendToSocket(socketId, type, data) / sendToUser(userId, type, data) (requires redis + onConnect to set userId)
  • Broadcast helpers: broadcast(type, data) / broadcastRoom(room, type, data) convenience methods
  • Presence: isUserOnline(userId) checks Redis user-socket mapping
  • Connection observability: rt.connectedCount getter

Adapters

  • @skweb/ws - Native WebSocket (JSON envelope { type, data?, ackId? })
  • @skweb/socketio - Socket.IO (native events + ack bridging)

Cross-Service Realtime via NATS

RealtimeFramework can be exposed as a Moleculer service so that web-api (or any other process) can push messages to online users via NATS RPC, without holding a WebSocket connection itself.

// realtime-worker/broker.ts
import { createMicroserviceBroker, createRealtimeService } from '@skweb/microservice'
import { framework } from './framework.js'

const broker = createMicroserviceBroker({
  nodeID: 'realtime-1',
  transporter: { type: 'NATS', options: { url: process.env.NATS_URL } }
})

broker.createService(createRealtimeService(framework))
await broker.start()
// web-api/utils/realtime-client.ts
import { createMicroserviceClient, RealtimeClient } from '@skweb/microservice'

const sc = createMicroserviceClient({
  nodeID: 'web-api',
  transporter: { type: 'NATS', options: { url: process.env.NATS_URL } }
})
const rt = new RealtimeClient(sc)
await sc.start()

// In a controller:
await rt.sendToUser('user-42', 'notification', { message: 'order shipped' })
const online = await rt.isUserOnline('user-42')

Available RPC actions exposed by createRealtimeService():

| Action | Params | Returns | |--------|--------|---------| | realtime.sendToUser | { userId, type, data? } | void | | realtime.sendToSocket | { socketId, type, data? } | void | | realtime.isUserOnline | { userId } | boolean | | realtime.broadcast | { type, data? } | void | | realtime.broadcastRoom | { room, type, data? } | void | | realtime.getConnectedCount | — | number |

License

MIT