init
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m31s

This commit is contained in:
2025-07-01 09:33:43 +07:00
parent 3a26f09a01
commit 331aba4489
156 changed files with 1206219 additions and 146 deletions

View File

@@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadCharacters } from '@/lib/characterLoader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const characters = await loadCharacters([id], locale)
const char = characters[id]
if (!char) {
return NextResponse.json({ error: 'Character not found' }, { status: 404 })
}
return NextResponse.json(char)
}

View File

@@ -0,0 +1,20 @@
import { loadCharacters } from "@/lib/characterLoader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const charIds = body.charIds as string[];
const { locale } = await params;
if (!Array.isArray(charIds) || charIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid charIds' }, { status: 400 });
}
const characters = await loadCharacters(charIds, locale);
return NextResponse.json(characters);
} catch {
return NextResponse.json({ error: 'Failed to load characters' }, { status: 500 });
}
}

View File

@@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadLightcones } from '@/lib/lighconeLoader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const lightcones = await loadLightcones([id], locale)
const lightcone = lightcones[id]
if (!lightcone) {
return NextResponse.json({ error: 'Lightcone not found' }, { status: 404 })
}
return NextResponse.json(lightcone)
}

View File

@@ -0,0 +1,20 @@
import { loadLightcones } from "@/lib/lighconeLoader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const lightconeIds = body.lightconeIds as string[];
const { locale } = await params;
if (!Array.isArray(lightconeIds) || lightconeIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid lightconeIds' }, { status: 400 });
}
const lightcones = await loadLightcones(lightconeIds, locale);
return NextResponse.json(lightcones);
} catch {
return NextResponse.json({ error: 'Failed to load lightcones' }, { status: 500 });
}
}

View File

@@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadRelics } from '@/lib/relicLoader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const relics = await loadRelics([id], locale)
const relic = relics[id]
if (!relic) {
return NextResponse.json({ error: 'Relic not found' }, { status: 404 })
}
return NextResponse.json(relic)
}

View File

@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from "next/server";
import { loadRelics } from "@/lib/relicLoader";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const relicIds = body.relicIds as string[];
const { locale } = await params;
if (!Array.isArray(relicIds) || relicIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid relicIds' }, { status: 400 });
}
const relics = await loadRelics(relicIds, locale);
return NextResponse.json(relics);
} catch {
return NextResponse.json({ error: 'Failed to load relics' }, { status: 500 });
}
}

View File

@@ -0,0 +1,11 @@
import { loadConfigMaze } from "@/lib/configMazeLoader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const configMaze = await loadConfigMaze();
return NextResponse.json(configMaze);
} catch {
return NextResponse.json({ error: 'Failed to load config maze' }, { status: 500 });
}
}

View File

@@ -0,0 +1,11 @@
import { loadMainAffix } from "@/lib/affixLoader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const mainAffix = await loadMainAffix();
return NextResponse.json(mainAffix);
} catch {
return NextResponse.json({ error: 'Failed to load main affix' }, { status: 500 });
}
}

View File

@@ -0,0 +1,73 @@
import { NextRequest, NextResponse } from 'next/server'
import axios from 'axios'
import net from 'net'
function isPrivateHost(hostname: string): boolean {
if (
hostname === 'localhost' ||
hostname.startsWith('127.') ||
hostname.startsWith('10.') ||
hostname.startsWith('192.168.') ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)
) {
return true
}
if (net.isIP(hostname)) {
return true
}
return false
}
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { serverUrl, method, ...payload } = body
if (!serverUrl) {
return NextResponse.json({ error: 'Missing serverUrl' }, { status: 400 })
}
if (!method) {
return NextResponse.json({ error: 'Missing method' }, { status: 400 })
}
let url = serverUrl.trim()
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = `http://${url}`
}
const parsed = new URL(url)
if (isPrivateHost(parsed.hostname)) {
return NextResponse.json(
{ error: `Connection to private/internal address (${parsed.hostname}) is not allowed` },
{ status: 403 }
)
}
let response
switch (method.toUpperCase()) {
case 'GET':
const queryString = new URLSearchParams(payload as any).toString()
const fullUrl = queryString ? `${url}?${queryString}` : url
response = await axios.get(fullUrl)
break
case 'POST':
response = await axios.post(url, payload)
break
case 'PUT':
response = await axios.put(url, payload)
break
case 'DELETE':
response = await axios.delete(url, { data: payload })
break
default:
return NextResponse.json({ error: `Unsupported method: ${method}` }, { status: 405 })
}
return NextResponse.json(response.data)
} catch (err: any) {
return NextResponse.json({ error: err.message || 'Proxy failed' }, { status: 500 })
}
}

View File

@@ -0,0 +1,11 @@
import { loadSubAffix } from "@/lib/affixLoader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const subAffix = await loadSubAffix();
return NextResponse.json(subAffix);
} catch {
return NextResponse.json({ error: 'Failed to load sub affix' }, { status: 500 });
}
}