style: format code with prettier
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
import { promises as fs } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { withAdmin } from '@/lib/api-handler'
|
||||
import { apiError, apiOk } from '@/lib/api-response'
|
||||
import { PERMS } from '@/lib/permissions'
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError, apiOk } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
|
||||
const EXTERNAL_TEXTS_PATH = path.join(
|
||||
process.cwd(),
|
||||
'public/nitro-assets/gamedata/ExternalTexts.json',
|
||||
)
|
||||
const EXTERNAL_TEXTS_PATH = path.join(process.cwd(), "public/nitro-assets/gamedata/ExternalTexts.json");
|
||||
|
||||
/** GET - Read badge name/desc from ExternalTexts.json */
|
||||
export const GET = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request) => {
|
||||
const code = request.nextUrl.searchParams.get('code')?.toUpperCase()
|
||||
if (!code) return apiError('Missing code', 400)
|
||||
const code = request.nextUrl.searchParams.get("code")?.toUpperCase();
|
||||
if (!code) return apiError("Missing code", 400);
|
||||
|
||||
try {
|
||||
const raw = await fs.readFile(EXTERNAL_TEXTS_PATH, 'utf-8')
|
||||
const texts: Record<string, string> = JSON.parse(raw)
|
||||
const raw = await fs.readFile(EXTERNAL_TEXTS_PATH, "utf-8");
|
||||
const texts: Record<string, string> = JSON.parse(raw);
|
||||
|
||||
const name = texts[`badge_name_${code}`] ?? texts[`${code}_badge_name`] ?? ''
|
||||
const desc = texts[`badge_desc_${code}`] ?? texts[`${code}_badge_desc`] ?? ''
|
||||
const name = texts[`badge_name_${code}`] ?? texts[`${code}_badge_name`] ?? "";
|
||||
const desc = texts[`badge_desc_${code}`] ?? texts[`${code}_badge_desc`] ?? "";
|
||||
|
||||
return apiOk({ name, desc })
|
||||
return apiOk({ name, desc });
|
||||
} catch {
|
||||
return apiError('Failed to read ExternalTexts.json', 500)
|
||||
return apiError("Failed to read ExternalTexts.json", 500);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user