@kne/fastify-app-manager 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -263,7 +263,7 @@ await fastify.listen({ port: 3000 });
263
263
  |--------|------|------|--------|------|
264
264
  | name | string | 是 | - | slug:`^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$` |
265
265
  | label | string | 是 | - | 展示名 |
266
- | domain | string | 否 | - | 绑定 Host(唯一);冲突返回 409 |
266
+ | domain | string / null | 否 | - | 绑定 Host(唯一);冲突返回 409;空值存为 `null` |
267
267
  | icon | string | 否 | - | 图标 |
268
268
  | description | string | 否 | - | 描述 |
269
269
  | category | object / string | 否 | - | 应用分类(应用中心分组用),写入 `options.category`;推荐传 fastify-group 分组对象,对象只保留 `{ code, name }`,字符串原样保存 |
@@ -282,7 +282,7 @@ await fastify.listen({ port: 3000 });
282
282
  | 参数名 | 类型 | 必填 | 说明 |
283
283
  |--------|------|------|------|
284
284
  | name | string | 是 | 应用 slug |
285
- | label / domain / icon / description / env / pm2Config / options | - | 否 | 传入的字段才更新;`env` 按 patch 语义合并 |
285
+ | label / domain / icon / description / env / pm2Config / options | - | 否 | 传入的字段才更新;`env` 按 patch 语义合并;`domain` 传 `null` / `''` 解绑域名(存为 `null`) |
286
286
  | category | object / string / null | 否 | 合并写入 `options.category`(对象只保留 `{ code, name }`),不影响 `options` 其它键;传空值清除分类 |
287
287
  | isPublic | boolean | 否 | 合并写入 `options.isPublic`,不影响 `options` 其它键 |
288
288
  | entries | array / null | 否 | 整体替换 `options.entries`(规则同创建),不影响 `options` 其它键;传 `[]` / `null` 清空入口 |
@@ -23,7 +23,7 @@ module.exports = fp(async (fastify, options) => {
23
23
  properties: {
24
24
  name: { type: 'string' },
25
25
  label: { type: 'string' },
26
- domain: { type: 'string' },
26
+ domain: { type: ['string', 'null'] },
27
27
  icon: { type: 'string' },
28
28
  description: { type: 'string' },
29
29
  category: { type: ['object', 'string', 'null'] },
@@ -54,7 +54,7 @@ module.exports = fp(async (fastify, options) => {
54
54
  properties: {
55
55
  name: { type: 'string' },
56
56
  label: { type: 'string' },
57
- domain: { type: 'string' },
57
+ domain: { type: ['string', 'null'] },
58
58
  icon: { type: 'string' },
59
59
  description: { type: 'string' },
60
60
  category: { type: ['object', 'string', 'null'] },
@@ -181,6 +181,10 @@ module.exports = fp(async (fastify, options) => {
181
181
  }
182
182
  patch[k] = v;
183
183
  }
184
+ // 空域名存 null:domain 有唯一约束,多个应用存 '' 会冲突
185
+ if (patch.domain !== undefined) {
186
+ patch.domain = patch.domain || null;
187
+ }
184
188
  if (patch.domain) {
185
189
  const domainTaken = await models.app.findOne({ where: { domain: patch.domain } });
186
190
  if (domainTaken && domainTaken.name !== name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-app-manager",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Fastify 单机应用市场插件:版本上传、PM2 托管、路径/域名反代与日志 SSE",
5
5
  "main": "index.js",
6
6
  "scripts": {