支持自部署需求管理、交付流程与飞书集成
This commit is contained in:
1 parent
2149aeb6ed
commit
51a2e548f2
152 files changed
+8652
-6394
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { assertSameOrigin, authFailure, AuthError, jsonResponse, readJsonObject, requireApiUser } from '@/lib/server/auth';
|
||||
import { feishuStatus, parseFeishuDeliveryQuery, retryFeishuNotification, testFeishuBot } from '@/lib/server/feishu-notifications';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
export const dynamic = 'force-dynamic';
|
||||
export async function GET(request: Request) {
|
||||
try { await requireApiUser({ admin: true }); return jsonResponse(feishuStatus(parseFeishuDeliveryQuery(new URL(request.url).searchParams))); }
|
||||
catch (error) { return authFailure(error); }
|
||||
}
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
assertSameOrigin(request);
|
||||
await requireApiUser({ admin: true });
|
||||
const query = parseFeishuDeliveryQuery(new URL(request.url).searchParams);
|
||||
const body = await readJsonObject(request);
|
||||
if (body.action === 'test') await testFeishuBot();
|
||||
else if (body.action === 'retry') retryFeishuNotification(body.id);
|
||||
else throw new AuthError('不支持的操作。');
|
||||
return jsonResponse(feishuStatus(query));
|
||||
} catch (error) { return authFailure(error); }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { assertSameOrigin, authFailure, createAccount, jsonResponse, listAccounts, readJsonObject, requireApiUser, updateAccount } from '@/lib/server/auth';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const admin = await requireApiUser({ admin: true });
|
||||
return jsonResponse({ users: listAccounts(admin.userId) });
|
||||
} catch (error) { return authFailure(error); }
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
assertSameOrigin(request);
|
||||
const admin = await requireApiUser({ admin: true });
|
||||
return jsonResponse({ user: await createAccount(admin.userId, await readJsonObject(request)) }, 201);
|
||||
} catch (error) { return authFailure(error); }
|
||||
}
|
||||
|
||||
export async function PATCH(request: Request) {
|
||||
try {
|
||||
assertSameOrigin(request);
|
||||
const admin = await requireApiUser({ admin: true });
|
||||
return jsonResponse({ user: await updateAccount(admin.userId, await readJsonObject(request)) });
|
||||
} catch (error) { return authFailure(error); }
|
||||
}
|
||||
Reference in new issue
Block a user