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

midway-fatcms

v0.0.22

Published

This is a midway component sample

Readme

midway-fatcms

FatCMS 服务端核心组件(Midway.js Component)。提供配置驱动的 CRUD、动态 API、代理网关、标准 CRUD 页面、权限与多站点等能力,由宿主应用(如 fatcms-server)引入并启动。

在 FatCMS 体系中的位置

fatcms-web          管理端 / 工作台前端(React + Vite)
       │  HTTP /ns/*
       ▼
fatcms-server       可运行的 Midway 宿主(配置、启动、PM2)
       │  imports: midway-fatcms
       ▼
midway-fatcms       本仓库:业务能力、Controller、Service、CRUD 引擎

| 项目 | 职责 | |------|------| | midway-fatcms | 平台能力库:网关、管理 API、CRUD-Pro、分表、AnyAPI、Proxy、标准 CRUD 等 | | fatcms-server | 运行时宿主:依赖本包,写入数据库 / Redis / OSS 等环境配置并启动服务(默认端口 7002) | | fatcms-web | 前端控制台:DevOps 配置页、标准 CRUD 设计/预览、工作台壳子 |

本地联调时,前端将 /ns 代理到 http://127.0.0.1:7002

核心能力

1. CRUD-Pro 引擎

配置驱动的 SQL 生成与执行,支持 MySQL / PostgreSQL / SQL Server。

  • 简易 CRUD:sqlSimpleName 一键生成增删改查 / 分页
  • Mongo 风格条件:$gt / $in / $like / $or
  • 字段过滤、校验、权限、默认值、软删除、标准审计字段
  • 关联填充:字典、系统配置、账号、工作台、自定义 Link
  • 自定义模板 SQL(@@placeholder)、事务

三层 API:

| 层次 | 入口 | 场景 | |------|------|------| | 便捷层 | CurdProService.getQuickCrud()CrudProQuick | 单表快速操作 | | 分表层 | CurdProService.getShardingCrud()ShardingCrudPro | 按年/月/日/范围/哈希分表 | | 协调层 | CurdMixService.executeCrud() | CRUD + 关联数据填充 |

2. 接口引擎(Gateway)

| 类型 | 路径前缀 | 说明 | |------|----------|------| | CRUD API | /ns/gw/crudApi/execute/:methodCode | 按方法码执行已配置的 CRUD | | AnyAPI(FaaS) | /ns/gw/anyApi/execute/:methodCode | 沙箱执行自定义 JS(可调 CRUD / HTTP) | | Proxy API | /ns/gw/proxy/* | 反向代理上游,负载均衡 / 限流等 | | 标准 CRUD | /ns/gw/api/crudStd/* | 零代码标准页面对应的列表/详情/增删改/动作 | | 公共 API | /ns/gw/api/publicApi/* | 工作台菜单、枚举、应用信息等 | | 文件 / 文档 | /ns/gw/file/*/ns/gw/doc/* | 上传下载、文档库 | | 异步任务 | /ns/gw/AsyncTask/* | 导出等异步任务 |

3. 管理 API(DevOps)

路径前缀多为 /ns/api/manage/*,配合功能码权限,覆盖:

应用 / 页面 / 工作台、CRUD 方法与标准 CRUD 设计、AnyAPI / ProxyAPI、数据字典、系统配置、菜单、账号与角色权限、文件与文档库、部署与资源上传、流程配置等。

4. 认证与多站点

  • 登录鉴权:/ns/api/auth,会话基于 Redis
  • 权限中间件:checkLogin / checkRole / checkPermission
  • 工作台(Workbench)维度隔离站点配置与菜单;接口可按 workbench_code 限制可见范围
  • 应用渲染入口:/ns/app

5. 其他

  • 异步任务与 Excel 导出
  • 简单流程引擎(配置 + 实例)
  • 定时任务调度、集群缓存刷新(Redis Pub/Sub)
  • 敏感配置字段 AES 解密(encryptedFieldList

技术栈

  • Midway.js 3.x + Koa + TypeScript
  • MySQL / PostgreSQL / SQL Server
  • Redis、阿里云 OSS、EJS 视图

目录结构

midway-fatcms/
├── src/
│   ├── config/                 # 组件默认配置
│   ├── controller/
│   │   ├── gateway/            # 对外网关(CRUD / AnyAPI / Proxy / 标准 CRUD…)
│   │   ├── manage/             # DevOps 管理接口
│   │   ├── myinfo/             # 登录与个人信息
│   │   └── render/             # 应用渲染
│   ├── libs/
│   │   ├── crud-pro/           # CRUD-Pro 核心
│   │   ├── crud-pro-quick/     # 快捷 CRUD
│   │   ├── crud-sharding/      # 分表
│   │   └── utils/
│   ├── middleware/             # 全局、鉴权、事务、缓存、分布式锁
│   ├── models/                 # 实体与类型
│   ├── schedule/               # 定时任务
│   ├── service/                # 业务服务(curd / crudstd / anyapi / proxyapi / flow…)
│   └── configuration.ts        # 组件生命周期
├── skills/midway-fatcms/       # CRUD / 分表等使用文档(Skill)
├── ddl/                        # 库表初始化脚本(如有)
└── package.json

作为组件引入

在宿主应用(参考 fatcms-server)中:

import { Configuration } from '@midwayjs/core';
import * as fatcms from 'midway-fatcms';
import { join } from 'path';

@Configuration({
  imports: [fatcms],
  importConfigs: [join(__dirname, './config')],
})
export class ContainerLifeCycle {}

宿主需自行配置:

  • 数据库连接(mysql2 / postgres2 / sqlserver2
  • Redis、OSS(按需)
  • keys、超级管理员、encryptedFieldList

默认对外前缀:

| 前缀 | 用途 | |------|------| | /ns/api | 管理端、鉴权、助手工具 | | /ns/gw | 网关类对外接口 | | /ns/app | 应用渲染 | | /ns/static | 静态资源 |

业务侧使用 CRUD(示例)

import { Provide, Inject } from '@midwayjs/core';
import { CurdProService, SqlDbType } from 'midway-fatcms';

@Provide()
export class OrderService {
  @Inject()
  curdProService: CurdProService;

  async getOrders() {
    const quick = this.curdProService.getQuickCrud({
      sqlDatabase: 'mydb',
      sqlDbType: SqlDbType.mysql,
      sqlTable: 't_order',
    });

    const page = await quick.findPage({
      condition: { status: 'paid' },
      pageNo: 1,
      pageSize: 20,
      orderBy: 'created_at DESC',
    });

    return { list: page.rows, total: page.totalCount };
  }
}

开发与构建(本仓库)

本包以组件形式发布,一般不直接 dev 起 HTTP 服务;联调请用 fatcms-server

npm install
npm run build      # mwtsc
npm run lint
npm test
npm run cov

当前版本见 package.jsonversion 字段。

文档

更细的 CRUD / 分表 / 条件操作符 / 内置函数说明见:

License

MIT