Skip to content

Commit 43b95be

Browse files
committed
chore(config): optimize build settings and enable minification for improved performance
1 parent 064c1dd commit 43b95be

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ jobs:
4545
run: pnpm format --check
4646

4747
- name: Build
48-
run: pnpm build
48+
run: pnpm build --debug
4949
env:
5050
NEXT_TELEMETRY_DISABLED: 1
5151
NODE_OPTIONS: "--max_old_space_size=4096"
52+
NEXTJS_DEBUG: 1
5253

5354
- name: Install Playwright Browsers
5455
run: npx playwright install --with-deps

app/api/get-schema/[name]/route.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import path from "path";
1010
// }
1111

1212
// Helper function to safely join paths and prevent traversal
13-
function safeJoin(base: string, target: string): string | null {
13+
function safeJoin(base, target) {
1414
const targetPath = "." + path.normalize("/" + target);
1515
const joinedPath = path.join(base, targetPath);
1616
// Check if the resolved path is still within the base directory
@@ -20,8 +20,9 @@ function safeJoin(base: string, target: string): string | null {
2020
return null; // Path traversal detected or invalid path
2121
}
2222

23-
export async function GET(request: Request, { params }: { params: { name: string } }) {
24-
const schemaName = params.name;
23+
// Using named export without explicit type annotations
24+
export async function GET(req, context) {
25+
const schemaName = context.params?.name;
2526

2627
if (!schemaName) {
2728
return NextResponse.json({ error: "Schema name required" }, { status: 400 });
@@ -48,15 +49,16 @@ export async function GET(request: Request, { params }: { params: { name: string
4849
console.log(`Attempting to read schema file: ${filePath}`);
4950

5051
const fileContent = await fs.readFile(filePath, "utf-8");
51-
// Assert the type after parsing JSON to satisfy eslint
52-
const schemaJson = JSON.parse(fileContent) as Record<string, unknown>;
52+
// Parse JSON without type assertion
53+
const schemaJson = JSON.parse(fileContent);
5354

5455
return NextResponse.json(schemaJson);
5556
} catch (error) {
5657
console.error(`Error fetching schema ${safeSchemaName}:`, error);
5758
if (
5859
error instanceof Error &&
59-
(error as NodeJS.ErrnoException).code === "ENOENT"
60+
"code" in error &&
61+
error.code === "ENOENT"
6062
) {
6163
return NextResponse.json(
6264
{ error: `Schema '${safeSchemaName}' not found.` },

next.config.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@ const nextConfig = {
3030
unoptimized: true,
3131
},
3232

33-
// Configure build cache
33+
// Configure build optimizations
3434
experimental: {
35-
turbotrace: {
36-
enabled: true,
37-
},
35+
optimizeCss: true,
36+
optimizePackageImports: ['react', 'react-dom'],
3837
},
3938

4039
// Increase memory limit for builds
4140
onDemandEntries: {
4241
maxInactiveAge: 25 * 1000,
4342
pagesBufferLength: 4,
4443
},
44+
45+
// Minify
46+
swcMinify: true,
47+
48+
// Disable telemetry
49+
typescript: {
50+
ignoreBuildErrors: false,
51+
},
4552
};
4653

4754
export default nextConfig;

0 commit comments

Comments
 (0)