fetch car catalog image with flag
MODIFY
src/server/rest/service/CarService.ts
src/server/rest/service/CarService.ts
@@ -41,6 +41,13 @@ export default class CarService {
}
// Filter
const filteredRequest = CarSecurity.filterCarCatalogsRequest(req.query);
+ const projectFields = ['id', 'vehicleModel', 'vehicleMake', 'vehicleModelVersion', 'batteryCapacityFull', 'fastchargeChargeSpeed', 'performanceTopspeed',
+ 'performanceAcceleration', 'rangeWLTP', 'rangeReal', 'efficiencyReal',
+ 'chargeStandardPower', 'chargeStandardPhase', 'chargeStandardPhaseAmp', 'chargeAlternativePower', 'chargeOptionPower',
+ 'chargeOptionPhaseAmp', 'chargeOptionPhase', 'chargeAlternativePhaseAmp', 'chargeAlternativePhase', 'chargePlug', 'fastChargePlug', 'fastChargePowerMax', 'drivetrainPowerHP'];
+ if (filteredRequest.withImages) {
+ projectFields.push('image');
+ }
// Get the cars
const carCatalogs = await CarStorage.getCarCatalogs(
{
@@ -48,10 +55,7 @@ export default class CarService {
carMaker: filteredRequest.CarMaker ? filteredRequest.CarMaker.split('|') : null
},
{ limit: filteredRequest.Limit, skip: filteredRequest.Skip, sort: filteredRequest.Sort, onlyRecordCount: filteredRequest.OnlyRecordCount },
- ['id', 'vehicleModel', 'vehicleMake', 'vehicleModelVersion', 'batteryCapacityFull', 'fastchargeChargeSpeed', 'performanceTopspeed',
- 'performanceAcceleration', 'rangeWLTP', 'rangeReal', 'efficiencyReal', 'image',
- 'chargeStandardPower','chargeStandardPhase','chargeStandardPhaseAmp','chargeAlternativePower','chargeOptionPower',
- 'chargeOptionPhaseAmp','chargeOptionPhase','chargeAlternativePhaseAmp','chargeAlternativePhase', 'chargePlug', 'fastChargePlug','fastChargePowerMax', 'drivetrainPowerHP']
+ projectFields
);
// Filter
CarSecurity.filterCarCatalogsResponse(carCatalogs, req.user);

MODIFY
src/server/rest/service/security/CarSecurity.ts
src/server/rest/service/security/CarSecurity.ts
@@ -25,6 +25,7 @@ export default class CarSecurity {
const filteredRequest: HttpCarCatalogsRequest = {
Search: sanitize(request.Search),
CarMaker: sanitize(request.CarMaker),
+ withImages: UtilsSecurity.filterBoolean(request.withImages),
} as HttpCarCatalogsRequest;
UtilsSecurity.filterSkipAndLimit(request, filteredRequest);
UtilsSecurity.filterSort(request, filteredRequest);

MODIFY
src/types/requests/HttpCarRequest.ts
src/types/requests/HttpCarRequest.ts
@@ -6,6 +6,7 @@ import { UserCar } from '../User';
export interface HttpCarCatalogsRequest extends HttpDatabaseRequest {
Search?: string;
CarMaker?: string;
+ withImages?: boolean;
}
export interface HttpCarMakersRequest extends HttpDatabaseRequest {

fetch car catalog image with flag