2019-09-13 11:06:03 +02:00
|
|
|
const { getSearchRequest } = require("./db/searchRequest");
|
2020-02-03 13:11:40 +01:00
|
|
|
const { getRealEstateById } = require("./db/realEstate");
|
2020-02-13 10:43:30 +01:00
|
|
|
const { getKiviOriginalById } = require("./db/kiviOriginal");
|
2020-02-14 13:38:31 +01:00
|
|
|
const validator = require("validator");
|
2019-04-27 07:08:36 +02:00
|
|
|
|
2019-09-13 11:06:03 +02:00
|
|
|
const currentSearchRequest = async req => {
|
|
|
|
|
const searchRequestId =
|
|
|
|
|
req && req.params ? req.params["searchRequestId"] : null;
|
|
|
|
|
if (!searchRequestId) return null;
|
2019-04-27 07:08:36 +02:00
|
|
|
|
2019-09-13 11:06:03 +02:00
|
|
|
return await getSearchRequest(searchRequestId);
|
2019-05-16 19:58:48 +02:00
|
|
|
};
|
2020-02-03 13:11:40 +01:00
|
|
|
|
|
|
|
|
const currentRealEstate = async req => {
|
|
|
|
|
const realEstateId = req && req.params ? req.params["realEstateId"] : null;
|
|
|
|
|
if (!realEstateId) return null;
|
|
|
|
|
|
2020-02-07 12:26:29 +01:00
|
|
|
return await getRealEstateById(parseInt(realEstateId));
|
2020-02-03 13:11:40 +01:00
|
|
|
};
|
2020-02-13 10:43:30 +01:00
|
|
|
const currentKiviRealEstate = async req => {
|
|
|
|
|
const kiviRealEstateId =
|
|
|
|
|
req && req.params ? req.params["kiviRealEstateId"] : null;
|
2020-02-14 13:38:31 +01:00
|
|
|
if (!kiviRealEstateId || !validator.isUUID(kiviRealEstateId)) return null;
|
2020-02-13 10:43:30 +01:00
|
|
|
|
|
|
|
|
return await getKiviOriginalById(kiviRealEstateId);
|
|
|
|
|
};
|
|
|
|
|
|
2019-04-27 07:08:36 +02:00
|
|
|
module.exports = {
|
2020-02-03 13:11:40 +01:00
|
|
|
currentSearchRequest,
|
2020-02-13 10:43:30 +01:00
|
|
|
currentRealEstate,
|
|
|
|
|
currentKiviRealEstate
|
2019-05-16 19:58:48 +02:00
|
|
|
};
|