Very minimal MVP
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user