feat: 更新依赖版本,优化用户模型构造函数和域名管理路由
This commit is contained in:
@@ -17,7 +17,7 @@ app
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { domain } = ctx.query.data;
|
||||
const { domain } = ctx.args.data;
|
||||
const domainInfos = await db.select().from(schema.kvAppDomain).where(eq(schema.kvAppDomain.domain, domain)).limit(1);
|
||||
const domainInfo = domainInfos[0];
|
||||
if (!domainInfo || !domainInfo.appId) {
|
||||
@@ -38,11 +38,20 @@ app
|
||||
path: 'app-domain',
|
||||
key: 'create',
|
||||
middleware: ['auth'],
|
||||
description: '创建应用域名绑定',
|
||||
metadata: {
|
||||
args: {
|
||||
data: z.object({
|
||||
domain: z.string().describe('域名'),
|
||||
appId: z.string().describe('应用ID'),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const uid = tokenUser.uid;
|
||||
const { domain, appId } = ctx.query.data || {};
|
||||
const { domain, appId } = ctx.args.data || {};
|
||||
if (!domain || !appId) {
|
||||
ctx.throw(400, 'domain and appId are required');
|
||||
}
|
||||
@@ -58,11 +67,21 @@ app
|
||||
path: 'app-domain',
|
||||
key: 'update',
|
||||
middleware: ['auth'],
|
||||
metadata: {
|
||||
args: {
|
||||
data: z.object({
|
||||
id: z.string().optional().describe('域名ID'),
|
||||
domain: z.string().optional().describe('域名'),
|
||||
appId: z.string().optional().describe('应用ID'),
|
||||
status: z.string().describe('状态'),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const uid = tokenUser.uid;
|
||||
const { id, domain, appId, status } = ctx.query.data || {};
|
||||
const { id, domain, appId, status } = ctx.args.data || {};
|
||||
if (!domain && !id) {
|
||||
ctx.throw(400, 'domain and id are required at least one');
|
||||
}
|
||||
@@ -87,7 +106,7 @@ app
|
||||
if (domainInfo.uid !== uid) {
|
||||
ctx.throw(403, 'domain must be owned by the user');
|
||||
}
|
||||
if (!AppDomainHelper.checkCanUpdateStatus(domainInfo.status!, status)) {
|
||||
if (!AppDomainHelper.checkCanUpdateStatus(domainInfo.status!, status as any)) {
|
||||
ctx.throw(400, 'domain status can not be updated');
|
||||
}
|
||||
const updateData: any = {};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { eq, desc, and, like, or } from 'drizzle-orm';
|
||||
import { app, db, schema } from '../../app.ts';
|
||||
import { CustomError } from '@kevisual/router';
|
||||
import { filter } from '@kevisual/js-filter'
|
||||
import { z } from 'zod';
|
||||
app
|
||||
@@ -77,7 +76,7 @@ app
|
||||
const tokenUser = ctx.state.tokenUser;
|
||||
const id = ctx.query.id;
|
||||
if (!id) {
|
||||
throw new CustomError('id is required');
|
||||
ctx.throw(400, 'id is required');
|
||||
}
|
||||
const result = await db
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user