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

huafua_chatroom

v1.0.0

Published

socket.io based chatroom.v2

Readme

基于 socket.io 的聊天室 V2

本小项目基于socket.io开发,结合express构建一个页面聊天系统,主要特点如下:

  • 服务器端使用express

  • 数据库操作使用基于sqlite3的自定义的huafua_sqlite-db

  • 前后端分离,前端使用axios进行服务器请求,使用socket.io实现消息通讯

  • 用户可群发或单独向某个人发送消息

  • 有新用户接入、用户退出,服务器主动推送最新用户清单

  • 在用户清单界面显示有来自谁的新消息,有几条

    新消息通知

  • 默认显示登录面板,点击登录显示聊天界面,注销后显示登录面板 登录才可聊天

需在其他项目是直接使用本项目中的聊天功能,参考如下test创建过程:

  • 初始化项目

    mkdir test
    cd test
    npm init -y
  • 安装相关依赖

    cnpm install -S express huafua_sqlite-db socket.io
  • 引用本项目中的chatroomtest项目根目录,并在根目录创建存放静态文件目录www

  • 创建app.js文件,代码如下

    var http = require("http");
    var path = require("path");
    var express = require("express");
    var chatroom = require("./chatroom.v2");
    //var chatroom=require("huafua_chatroom");
    var app = express();
    app.use(express.static(path.resolve(__dirname, "www")));
    var server = http.Server(app);
    chatroom(server, app);
    server.listen(8080);
  • www目录中创建静态文件index.html,代码如下:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>聊天室</title>
        <script src="/socket.io/socket.io.js"></script>
        <link rel="stylesheet" type="text/css" href="/chatroom/index.css" />
        <script src="/chatroom/axios.min.js"></script>
        <script src="/chatroom/index.js"></script>
        <style>
          body {
            display: flex;
            position: absolute;
          }
    
          body div[class*="container"] {
            height: 600px;
            margin: 5px;
            flex: 1;
          }
        </style>
      </head>
    
      <body>
        <div class="container1"></div>
        <div class="container2"></div>
        <div class="container3"></div>
        <script>
          new Chatroom({
            containerSelector: ".container1",
            user: {
              id: "one",
              name: "一心一意"
            }
          });
          new Chatroom({
            containerSelector: ".container2",
            user: {
              id: "two",
              name: "双龙戏珠"
            }
          });
          new Chatroom({
            containerSelector: ".container3",
            user: {
              id: "three",
              name: "三顾茅庐"
            }
          });
        </script>
      </body>
    </html>
  • 启动服务器

    node app.js

    至此,差不多就行了!