fix(14): cast companies-list id to Number to match resolve route's z.number() schema
companies.id is BIGINT and node-postgres serializes it as a string. The manual-search fallback (D-05) fetches from this route and sends the id straight through to POST /company-matches/[id]/resolve, whose Zod schema requires a JS number with no coercion — every manual-search resolution was rejected with 400. Every other PAX8 route in this phase already casts bigint columns via Number(); this route was the one omission. Found by code review (14-REVIEW.md, CR-01).
This commit is contained in:
parent
1f5a65ecc1
commit
d56db023be
1 changed files with 5 additions and 1 deletions
|
|
@ -10,7 +10,11 @@ export async function GET() {
|
|||
const result = await postgresClient.query(
|
||||
`SELECT id, company_name FROM companies WHERE is_active = true AND is_deleted = false ORDER BY company_name ASC`
|
||||
);
|
||||
return NextResponse.json(result.rows);
|
||||
const companies = result.rows.map((row) => ({
|
||||
id: Number(row.id),
|
||||
company_name: row.company_name,
|
||||
}));
|
||||
return NextResponse.json(companies);
|
||||
} catch (error) {
|
||||
console.error('Error fetching companies list:', error);
|
||||
return NextResponse.json({ error: 'Failed to fetch companies list' }, { status: 500 });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue