Updates to database and API for dropdowns.

This commit is contained in:
Eric Gullickson
2025-11-11 10:29:02 -06:00
parent 3dc0f2a733
commit 8376aee7ed
157 changed files with 2573659 additions and 1548221 deletions

View File

@@ -13,6 +13,7 @@ import {
ModelsQuery,
TrimsQuery,
EnginesQuery,
TransmissionsQuery,
VINDecodeRequest
} from '../models/requests';
import { logger } from '../../../core/logging/logger';
@@ -57,12 +58,12 @@ export class PlatformController {
}
/**
* GET /api/platform/models?year={year}&make_id={id}
* GET /api/platform/models?year={year}&make={make}
*/
async getModels(request: FastifyRequest<{ Querystring: ModelsQuery }>, reply: FastifyReply): Promise<void> {
try {
const { year, make_id } = request.query;
const models = await this.vehicleDataService.getModels(this.pool, year, make_id);
const { year, make } = request.query as any;
const models = await this.vehicleDataService.getModels(this.pool, year, make);
reply.code(200).send({ models });
} catch (error) {
logger.error('Controller error: getModels', { error, query: request.query });
@@ -71,12 +72,12 @@ export class PlatformController {
}
/**
* GET /api/platform/trims?year={year}&model_id={id}
* GET /api/platform/trims?year={year}&make={make}&model={model}
*/
async getTrims(request: FastifyRequest<{ Querystring: TrimsQuery }>, reply: FastifyReply): Promise<void> {
try {
const { year, model_id } = request.query;
const trims = await this.vehicleDataService.getTrims(this.pool, year, model_id);
const { year, make, model } = request.query as any;
const trims = await this.vehicleDataService.getTrims(this.pool, year, make, model);
reply.code(200).send({ trims });
} catch (error) {
logger.error('Controller error: getTrims', { error, query: request.query });
@@ -85,12 +86,12 @@ export class PlatformController {
}
/**
* GET /api/platform/engines?year={year}&model_id={id}&trim_id={id}
* GET /api/platform/engines?year={year}&make={make}&model={model}&trim={trim}
*/
async getEngines(request: FastifyRequest<{ Querystring: EnginesQuery }>, reply: FastifyReply): Promise<void> {
try {
const { year, model_id, trim_id } = request.query;
const engines = await this.vehicleDataService.getEngines(this.pool, year, model_id, trim_id);
const { year, make, model, trim } = request.query as any;
const engines = await this.vehicleDataService.getEngines(this.pool, year, make, model, trim);
reply.code(200).send({ engines });
} catch (error) {
logger.error('Controller error: getEngines', { error, query: request.query });
@@ -98,6 +99,20 @@ export class PlatformController {
}
}
/**
* GET /api/platform/transmissions?year={year}&make={make}&model={model}
*/
async getTransmissions(request: FastifyRequest<{ Querystring: TransmissionsQuery }>, reply: FastifyReply): Promise<void> {
try {
const { year, make, model } = request.query as any;
const transmissions = await this.vehicleDataService.getTransmissions(this.pool, year, make, model);
reply.code(200).send({ transmissions });
} catch (error) {
logger.error('Controller error: getTransmissions', { error, query: request.query });
reply.code(500).send({ error: 'Failed to retrieve transmissions' });
}
}
/**
* GET /api/platform/vehicle?vin={vin}
*/