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

asai-nodejs-hostweb

v0.2.33

Published

asai for you

Readme

asai-nodejs-hostweb — Web 系统功能插件

功能概述

asai-nodejs-hostweb 是系统的Web 功能插件,为 Web 应用提供四大模块功能:库工具(lib-install)API 接口系统管理(sys)WebSocket 服务。它作为 asai-nodejs-host 的配套插件,注入具体的业务处理逻辑。


文件结构

asai-nodejs-hostweb/
├── README.md
└── asai-nodejs-hostweb/
    ├── index.ts              ← 入口文件:整合四大模块
    ├── lib-install/
    │   ├── Index.ts          ← 库工具导出(As, AsSys, AsNodeTool, AsCode, AsAES, AsDb)
    │   └── common/
    │       ├── As.ts         ← 基础工具函数
    │       ├── AsSys.ts      ← 系统方法
    │       ├── AsNodeTool.ts ← Node.js 工具方法
    │       ├── AsCode.ts     ← 编解码工具
    │       ├── AsAES.ts      ← AES 加解密
    │       └── AsDb.ts       ← 数据库插件路由(含 AsDbChannelFile, AsDbPlugs)
    ├── api/
    │   ├── Index.ts          ← API 路由注册(13 个 API 端点)
    │   ├── init/
    │   │   └── code.ts       ← 初始化代码
    │   ├── user/
    │   │   └── userinfo.ts   ← 用户信息 API
    │   ├── channel/
    │   │   ├── channelsqliteserver.ts  ← SQLite 通道服务
    │   │   ├── channelfileserver.ts    ← 文件通道服务
    │   │   └── channeljsonserver.ts    ← JSON 通道服务
    │   └── common/
    │       ├── mmmanage.ts    ← 会员管理
    │       ├── filemanage.ts  ← 文件管理
    │       ├── jsonmanage.ts  ← JSON 管理
    │       ├── logmanage.ts   ← 日志管理
    │       ├── sqlitemanage.ts← SQLite 管理
    │       ├── shellmanage.ts ← Shell 命令执行
    │       ├── dirmanage.ts   ← 目录管理
    │       └── zipmanage.ts   ← ZIP 压缩管理
    ├── sys/
    │   ├── Index.ts          ← 系统路由注册(9 个系统端点)
    │   └── common/
    │       ├── file.ts       ← 文件系统操作
    │       ├── zip.ts        ← 压缩操作
    │       ├── json.ts       ← JSON 操作
    │       ├── shell.ts      ← Shell 执行
    │       ├── upload.ts     ← 文件上传
    │       ├── update.ts     ← 更新操作
    │       ├── upgrade.ts    ← 升级操作
    │       ├── guard.ts      ← 守护进程
    │       └── info.ts       ← 系统信息
    └── ws/
        ├── Index.ts          ← WebSocket 路由注册(5 个 WS 端点)
        ├── common/
        │   └── ping.ts       ← WS 心跳检测
        ├── chat/
        │   └── web.ts        ← Web 聊天处理
        └── user/
            ├── exit.ts       ← 用户退出
            ├── login.ts      ← 用户登录
            └── online.ts     ← 在线用户管理

入口文件 — index.ts

import libInstall from './lib-install/Index';
import api from './api/Index';
import sys from './sys/Index';
import ws from './ws/Index';

const initHostWeb: any = {
  ...libInstall,    // 展开库工具(As, AsSys, AsNodeTool, AsCode, AsAES, AsDb)
  api,              // API 路由容器
  sys,              // 系统路由容器
  ws,               // WebSocket 路由容器
};

export default initHostWeb;

模块分析

1. lib-install — 基础库工具

提供系统运行所需的基础能力:

| 模块 | 说明 | |------|------| | As | 基础工具函数 | | AsSys | 系统级方法 | | AsNodeTool | Node.js 工具方法 | | AsCode | 编解码工具 | | AsAES | AES 加解密(aes-256-gcm) | | AsDb | 数据库插件路由(封装 asai-nodejs-db 调用) |

2. api — API 接口层

通过 Index.ts 注册 13 个 API 端点,挂载到 $asai.$lib.api

| 路由 | 模块文件 | 说明 | |------|----------|------| | init/code | init/code | 初始化代码 | | user/userinfo | user/userinfo | 用户信息查询 | | asaichannel/sqlite | channel/channelsqliteserver | SQLite 通道服务 | | asaichannel/file | channel/channelfileserver | 文件通道服务 | | asaichannel/json | channel/channeljsonserver | JSON 通道服务 | | asaimm/manage | common/mmmanage | 会员管理 | | asaifile/manage | common/filemanage | 文件管理 | | asaijson/manage | common/jsonmanage | JSON 管理 | | asailog/manage | common/logmanage | 日志管理 | | asaisqlite/manage | common/sqlitemanage | SQLite 管理 | | asaishell/manage | common/shellmanage | Shell 命令执行 | | asaidir/manage | common/dirmanage | 目录管理 | | asaizip/manage | common/zipmanage | ZIP 压缩管理 |

3. sys — 系统管理

通过 Index.ts 注册 9 个系统端点,挂载到 $asai.$lib.sys

| 路由 | 模块文件 | 说明 | |------|----------|------| | sys/file | common/file | 文件系统操作 | | sys/zip | common/zip | ZIP 压缩/解压 | | sys/json | common/json | JSON 数据操作 | | sys/shell | common/shell | Shell 命令执行 | | sys/upload | common/upload | 文件上传处理 | | sys/update | common/update | 系统更新 | | sys/upgrade | common/upgrade | 系统升级 | | sys/guard | common/guard | 守护进程检测 | | sys/info | common/info | 系统信息查询 |

4. ws — WebSocket 服务

通过 Index.ts 注册 5 个 WebSocket 端点,挂载到 $asai.$lib.ws

| 路由 | 模块文件 | 说明 | |------|----------|------| | ping | common/ping | WS 心跳检测(保持连接活跃) | | chat/web | chat/web | Web 聊天消息处理 | | user/exit | user/exit | 用户退出登录 | | user/login | user/login | 用户登录处理 | | user/online | user/online | 在线用户状态管理 |


使用示例

// 在 asai-nodejs-host 初始化时注入
import initHostWeb from './asai-nodejs-hostweb/index';

const hostWeb = initHostWeb;

// hostWeb 展开为:
// {
//   As, AsSys, AsNodeTool, AsCode, AsAES, AsDb,  // lib-install
//   api,                                           // API 路由容器
//   sys,                                           // 系统路由容器
//   ws                                             // WebSocket 路由容器
// }

// 这些模块在 asai-nodejs-host 初始化时被挂载到 $asai.$lib
// $asai.$lib.api['asaifile/manage'](...)
// $asai.$lib.sys['sys/file'](...)
// $asai.$lib.ws['user/login'](...)

依赖关系

asai-nodejs-host  (服务器引擎)
    └── asai-nodejs-hostweb  (Web 功能插件)
            └── asai-nodejs-db  (数据库操作)
            └── asai-nodejs-fs  (文件系统操作)
            └── asai-nodejs-zip (ZIP 压缩)

asai-nodejs-hostweb 是业务逻辑的核心插件,它通过 asai-nodejs-host 提供的路由机制,将具体的业务处理函数注册到对应的 API、系统管理和 WebSocket 路由中。


注意事项

  1. 本插件需配合 asai-nodejs-host 使用,通过 opt 参数注入处理器
  2. API 路由使用 $asai.$lib.api 命名空间,WS 路由使用 $asai.$lib.ws 命名空间
  3. lib-install 中的基础工具会在系统初始化时扩展到 $asai.$lib
  4. 各模块采用 require.context 风格的静态导入注册,启动时完成所有路由映射