Very minimal MVP

This commit is contained in:
Eric Gullickson
2025-08-23 09:54:22 -05:00
parent d60c3ec00e
commit 6683f1eeff
12 changed files with 661 additions and 13 deletions

View File

@@ -161,4 +161,75 @@ export class VehiclesController {
next(error);
}
};
getDropdownMakes = async (_req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const makes = await this.service.getDropdownMakes();
res.json(makes);
} catch (error: any) {
if (error.message === 'Failed to load makes') {
res.status(503).json({ error: 'Unable to load makes data' });
return;
}
next(error);
}
};
getDropdownModels = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const { make } = req.params;
if (!make) {
res.status(400).json({ error: 'Make parameter is required' });
return;
}
const models = await this.service.getDropdownModels(make);
res.json(models);
} catch (error: any) {
if (error.message === 'Failed to load models') {
res.status(503).json({ error: 'Unable to load models data' });
return;
}
next(error);
}
};
getDropdownTransmissions = async (_req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const transmissions = await this.service.getDropdownTransmissions();
res.json(transmissions);
} catch (error: any) {
if (error.message === 'Failed to load transmissions') {
res.status(503).json({ error: 'Unable to load transmissions data' });
return;
}
next(error);
}
};
getDropdownEngines = async (_req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const engines = await this.service.getDropdownEngines();
res.json(engines);
} catch (error: any) {
if (error.message === 'Failed to load engines') {
res.status(503).json({ error: 'Unable to load engines data' });
return;
}
next(error);
}
};
getDropdownTrims = async (_req: Request, res: Response, next: NextFunction): Promise<void> => {
try {
const trims = await this.service.getDropdownTrims();
res.json(trims);
} catch (error: any) {
if (error.message === 'Failed to load trims') {
res.status(503).json({ error: 'Unable to load trims data' });
return;
}
next(error);
}
};
}

View File

@@ -11,10 +11,17 @@ export function registerVehiclesRoutes(): Router {
const router = Router();
const controller = new VehiclesController();
// All vehicle routes require authentication
// Dropdown Data Routes (no auth required for form population)
router.get('/api/vehicles/dropdown/makes', controller.getDropdownMakes);
router.get('/api/vehicles/dropdown/models/:make', controller.getDropdownModels);
router.get('/api/vehicles/dropdown/transmissions', controller.getDropdownTransmissions);
router.get('/api/vehicles/dropdown/engines', controller.getDropdownEngines);
router.get('/api/vehicles/dropdown/trims', controller.getDropdownTrims);
// All other vehicle routes require authentication
router.use(authMiddleware);
// Routes
// CRUD Routes
router.post('/api/vehicles', controller.createVehicle);
router.get('/api/vehicles', controller.getUserVehicles);
router.get('/api/vehicles/:id', controller.getVehicle);