Files
old-web/app/helpers/url.js

33 lines
1022 B
JavaScript
Raw Normal View History

const { getSearchRequest } = require("./db/searchRequest");
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
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
return await getSearchRequest(searchRequestId);
2019-05-16 19:58:48 +02: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-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 = {
currentSearchRequest,
2020-02-13 10:43:30 +01:00
currentRealEstate,
currentKiviRealEstate
2019-05-16 19:58:48 +02:00
};