新增基于lxserver的音乐功能

This commit is contained in:
mtvpls
2026-04-13 23:17:57 +08:00
parent 7469cc1537
commit c82d7b3841
30 changed files with 2740 additions and 546 deletions
+33
View File
@@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { db } from '@/lib/db';
export async function getMusicV2Username(request: NextRequest): Promise<string | null> {
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) return null;
if (authInfo.username !== process.env.USERNAME) {
const userInfo = await db.getUserInfoV2(authInfo.username);
if (!userInfo || userInfo.banned) {
return null;
}
}
return authInfo.username;
}
export function unauthorized() {
return NextResponse.json({ success: false, error: { code: 'UNAUTHORIZED', message: 'Unauthorized' } }, { status: 401 });
}
export function badRequest(message: string, code = 'BAD_REQUEST') {
return NextResponse.json({ success: false, error: { code, message } }, { status: 400 });
}
export function internalError(message: string, details?: string) {
return NextResponse.json(
{ success: false, error: { code: 'INTERNAL_ERROR', message, details } },
{ status: 500 }
);
}