diff --git a/frontends/nextjs/src/app/api/dbal/schema/route.ts b/frontends/nextjs/src/app/api/dbal/schema/route.ts index da41b49dd..3424da801 100644 --- a/frontends/nextjs/src/app/api/dbal/schema/route.ts +++ b/frontends/nextjs/src/app/api/dbal/schema/route.ts @@ -182,7 +182,7 @@ function handleApprove(registry: SchemaRegistry, registryPath: string, id?: stri } function handleReject(registry: SchemaRegistry, registryPath: string, id?: string) { - if (!id) { + if (id === null || id === undefined || id === '') { return NextResponse.json( { status: 'error', error: 'Migration ID required' }, { status: 400 } diff --git a/frontends/nextjs/src/app/api/github/actions/runs/[runId]/logs/route.ts b/frontends/nextjs/src/app/api/github/actions/runs/[runId]/logs/route.ts index afe19d493..1df3b84d2 100644 --- a/frontends/nextjs/src/app/api/github/actions/runs/[runId]/logs/route.ts +++ b/frontends/nextjs/src/app/api/github/actions/runs/[runId]/logs/route.ts @@ -48,7 +48,7 @@ export const GET = async (request: NextRequest, { params }: RouteParams) => { }) } catch (error) { const status = - typeof error === 'object' && error && 'status' in error + typeof error === 'object' && error !== null && 'status' in error ? Number((error as { status?: number }).status) : 500 const message = error instanceof Error ? error.message : 'Unknown error' diff --git a/frontends/nextjs/src/app/api/github/actions/runs/route.ts b/frontends/nextjs/src/app/api/github/actions/runs/route.ts index c59d0c18b..25134615b 100644 --- a/frontends/nextjs/src/app/api/github/actions/runs/route.ts +++ b/frontends/nextjs/src/app/api/github/actions/runs/route.ts @@ -30,7 +30,7 @@ export const GET = async (request: NextRequest) => { }) } catch (error) { const status = - typeof error === 'object' && error && 'status' in error + typeof error === 'object' && error !== null && 'status' in error ? Number((error as { status?: number }).status) : 500 const message = error instanceof Error ? error.message : 'Unknown error' diff --git a/frontends/nextjs/src/app/api/v1/[...slug]/route.ts b/frontends/nextjs/src/app/api/v1/[...slug]/route.ts index 347de8dc6..4dcc80ec6 100644 --- a/frontends/nextjs/src/app/api/v1/[...slug]/route.ts +++ b/frontends/nextjs/src/app/api/v1/[...slug]/route.ts @@ -81,7 +81,7 @@ async function handleRequest( if (['POST', 'PUT', 'PATCH'].includes(request.method)) { try { const text = await request.text() - if (text) { + if (text !== null && text !== undefined && text !== '') { body = JSON.parse(text) } } catch { @@ -124,18 +124,18 @@ async function handleRequest( if (!result.success) { // Map common errors to appropriate status codes - const errorMsg = result.error || 'Operation failed' - if (errorMsg.includes('not found')) { + const errorMsg = result.error ?? 'Operation failed' + if (errorMsg !== null && errorMsg !== undefined && errorMsg.includes('not found')) { return errorResponse(errorMsg, STATUS.NOT_FOUND) } - if (errorMsg.includes('required')) { + if (errorMsg !== null && errorMsg !== undefined && errorMsg.includes('required')) { return errorResponse(errorMsg, STATUS.BAD_REQUEST) } return errorResponse(errorMsg, STATUS.INTERNAL_ERROR) } // Build response with metadata - const responseData = result.meta + const responseData = result.meta !== null && result.meta !== undefined ? { data: result.data, ...(result.meta as Record) } : result.data diff --git a/frontends/nextjs/src/app/page.tsx b/frontends/nextjs/src/app/page.tsx index beaae4630..07d0bb83c 100644 --- a/frontends/nextjs/src/app/page.tsx +++ b/frontends/nextjs/src/app/page.tsx @@ -62,7 +62,7 @@ export default async function RootPage() { const pkg = await loadJSONPackage(`/home/rewrich/Documents/GitHub/metabuilder/packages/${route.packageId}`) const component = pkg?.components?.find(c => c.id === route.component || c.name === route.component) - if (component) { + if (component !== null && component !== undefined) { return renderJSONComponent(component, {}, {}) } } diff --git a/frontends/nextjs/src/lib/db/packages/data/get/get-package-data.ts b/frontends/nextjs/src/lib/db/packages/data/get/get-package-data.ts index 3a8779ce4..3219a2e70 100644 --- a/frontends/nextjs/src/lib/db/packages/data/get/get-package-data.ts +++ b/frontends/nextjs/src/lib/db/packages/data/get/get-package-data.ts @@ -9,6 +9,6 @@ export async function getPackageData(packageId: string): Promise { level: Number(p.level) as PageConfig['level'], componentTree: JSON.parse(p.componentTree) as PageConfig['componentTree'], requiresAuth: p.requiresAuth, - requiredRole: p.requiredRole ? toUserRole(p.requiredRole) : undefined, + requiredRole: p.requiredRole !== null && p.requiredRole !== undefined ? toUserRole(p.requiredRole) : undefined, })) } diff --git a/frontends/nextjs/src/lib/db/schemas/crud/add-schema.ts b/frontends/nextjs/src/lib/db/schemas/crud/add-schema.ts index 7371f7a57..5b15df9fd 100644 --- a/frontends/nextjs/src/lib/db/schemas/crud/add-schema.ts +++ b/frontends/nextjs/src/lib/db/schemas/crud/add-schema.ts @@ -12,9 +12,9 @@ export async function addSchema(schema: ModelSchema): Promise { labelPlural: schema.labelPlural, icon: schema.icon, fields: JSON.stringify(schema.fields), - listDisplay: schema.listDisplay ? JSON.stringify(schema.listDisplay) : null, - listFilter: schema.listFilter ? JSON.stringify(schema.listFilter) : null, - searchFields: schema.searchFields ? JSON.stringify(schema.searchFields) : null, - ordering: schema.ordering ? JSON.stringify(schema.ordering) : null, + listDisplay: schema.listDisplay !== null && schema.listDisplay !== undefined ? JSON.stringify(schema.listDisplay) : null, + listFilter: schema.listFilter !== null && schema.listFilter !== undefined ? JSON.stringify(schema.listFilter) : null, + searchFields: schema.searchFields !== null && schema.searchFields !== undefined ? JSON.stringify(schema.searchFields) : null, + ordering: schema.ordering !== null && schema.ordering !== undefined ? JSON.stringify(schema.ordering) : null, }) }