让只用 Shrimp 核心(RPC + 模块声明 + 内存 CRUD)的项目不必装
express / mongoose / bcrypt / jsonwebtoken,显著降低 install 时间。
- src/core.ts:0 重依赖入口(Shrimp / MemoryShrimpCrud / 类型)
- src/server.ts:在 core 之上再导出 ShrimpServer + MongoShrimpCrud
- package.json:加 exports 字段 + peerDependenciesMeta.optional
- Shrimp.ts:bcrypt 改 lazy import,只有走 Password 字段才触发
- MemoryShrimpCrud.populateItems:接 crudRegistry 参数(对齐 Mongo)
- ShrimpTableModule 构造时自动登记 crudRegistry,业务无需手动 wire
- 新增 test/crudRegistry.test.ts 验证自动登记 + relation 自动 populate
BREAKING: import { ShrimpServer } from 'shrimp-server' 不再可用,
请改为 'shrimp-server/server'。
26 lines
805 B
TypeScript
26 lines
805 B
TypeScript
/**
|
|
* Shrimp 服务端入口 — 包含 Express + Mongoose + JWT 实现
|
|
*
|
|
* 在 core 之上额外暴露:
|
|
* - ShrimpServer:Express Router + JWT 鉴权 + Mongo 连接
|
|
* - MongoShrimpCrud:Mongoose 数据源
|
|
* - 内置 User/Role/OperationLog 的 Mongoose Schema
|
|
*
|
|
* 这一入口需要消费方安装 peer 依赖:express / mongoose / jsonwebtoken / bcrypt。
|
|
* 不需要这些时请改从 'shrimp-server' 导入,不会触发任何 peer。
|
|
*/
|
|
|
|
// 再导出所有 core 的符号,'shrimp-server/server' 单一入口就够用
|
|
export * from "./core"
|
|
|
|
// ===== 服务端实现(Express + Mongoose + JWT) =====
|
|
export {
|
|
ShrimpServer,
|
|
UserSchema,
|
|
RoleSchema,
|
|
OperationLogSchema,
|
|
} from "./ShrimpServer"
|
|
|
|
// ===== Mongoose 数据源 =====
|
|
export { MongoShrimpCrud } from "./MongoShrimpCrud"
|