Email links now point to our URL and then redirect to the original property URL, ran prettier on the affected files
This commit is contained in:
156
index.js
156
index.js
@@ -1,19 +1,38 @@
|
||||
const welcome = require('./app/controllers/welcome').getWelcome;
|
||||
const { getRealEstateTypes, postRealEstateTypes } = require('./app/controllers/realEstateTypes');
|
||||
const { getRegion, postRegion } = require('./app/controllers/regions');
|
||||
const { getMunicipality, postMunicipality } = require('./app/controllers/municipalities');
|
||||
const { getSize, postSize } = require('./app/controllers/sizes');
|
||||
const { getGardenSize, postGardenSize } = require('./app/controllers/gardenSizes');
|
||||
const { getPrice, postPrice } = require('./app/controllers/prices');
|
||||
const { getQueryReview, postQueryReview } = require('./app/controllers/queryReview');
|
||||
const { getQuerySubmit, postQuerySubmit } = require('./app/controllers/querySubmit');
|
||||
const { getGoAgain } = require('./app/controllers/goAgain');
|
||||
const { getNeighborhood, postNeighborhood } = require('./app/controllers/neighborhoodMap');
|
||||
const { getUnsubscribe } = require('./app/controllers/unsubscribe');
|
||||
const { getRealEstates} = require('./app/controllers/realEstates');
|
||||
const schedule = require('node-schedule');
|
||||
const crawlAll = require('./app/services/crawlerService')
|
||||
const processNotifications = require('./app/services/notificationService')
|
||||
const welcome = require("./app/controllers/welcome").getWelcome;
|
||||
const {
|
||||
getRealEstateTypes,
|
||||
postRealEstateTypes
|
||||
} = require("./app/controllers/realEstateTypes");
|
||||
const { getRegion, postRegion } = require("./app/controllers/regions");
|
||||
const {
|
||||
getMunicipality,
|
||||
postMunicipality
|
||||
} = require("./app/controllers/municipalities");
|
||||
const { getSize, postSize } = require("./app/controllers/sizes");
|
||||
const {
|
||||
getGardenSize,
|
||||
postGardenSize
|
||||
} = require("./app/controllers/gardenSizes");
|
||||
const { getPrice, postPrice } = require("./app/controllers/prices");
|
||||
const {
|
||||
getQueryReview,
|
||||
postQueryReview
|
||||
} = require("./app/controllers/queryReview");
|
||||
const {
|
||||
getQuerySubmit,
|
||||
postQuerySubmit
|
||||
} = require("./app/controllers/querySubmit");
|
||||
const { getGoAgain } = require("./app/controllers/goAgain");
|
||||
const {
|
||||
getNeighborhood,
|
||||
postNeighborhood
|
||||
} = require("./app/controllers/neighborhoodMap");
|
||||
const { getUnsubscribe } = require("./app/controllers/unsubscribe");
|
||||
const { getRealEstates } = require("./app/controllers/realEstates");
|
||||
const { redirect } = require("./app/controllers/redirect");
|
||||
const schedule = require("node-schedule");
|
||||
const crawlAll = require("./app/services/crawlerService");
|
||||
const processNotifications = require("./app/services/notificationService");
|
||||
|
||||
let express = require("express");
|
||||
const path = require("path");
|
||||
@@ -23,7 +42,7 @@ const sendNotification = require("./app/lib/sendNotification");
|
||||
const scrapTheItems = require("./app/lib/scrapTheItems");
|
||||
const sequelize = require("./app/models/index").sequelize;
|
||||
const Twocheckout = require("2checkout-node");
|
||||
const layout = require('express-layout');
|
||||
const layout = require("express-layout");
|
||||
|
||||
const app = express();
|
||||
app.use(bodyParser.json());
|
||||
@@ -31,11 +50,11 @@ app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
const port = process.env.PORT || 5000;
|
||||
|
||||
app.set('views', path.join(__dirname, '/app/views'));
|
||||
app.set('view engine', 'ejs');
|
||||
app.set("views", path.join(__dirname, "/app/views"));
|
||||
app.set("view engine", "ejs");
|
||||
app.use(layout());
|
||||
|
||||
const compression = require('compression');
|
||||
const compression = require("compression");
|
||||
app.use(compression());
|
||||
|
||||
app.get("/api/sendnotifications", async (req, res) => {
|
||||
@@ -111,7 +130,7 @@ app.post("/api/payforalert", (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
tco.checkout.authorize(params, function (error, data) {
|
||||
tco.checkout.authorize(params, function(error, data) {
|
||||
if (error) {
|
||||
res.send(error.message);
|
||||
} else {
|
||||
@@ -120,64 +139,73 @@ app.post("/api/payforalert", (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/', welcome);
|
||||
app.get('/vrstanekretnine/:request_id', getRealEstateTypes);
|
||||
app.get('/vrstanekretnine', getRealEstateTypes);
|
||||
app.get("/", welcome);
|
||||
app.get("/vrstanekretnine/:request_id", getRealEstateTypes);
|
||||
app.get("/vrstanekretnine", getRealEstateTypes);
|
||||
|
||||
app.post('/vrstanekretnine/:request_id', postRealEstateTypes);
|
||||
app.post('/vrstanekretnine', postRealEstateTypes);
|
||||
app.post("/vrstanekretnine/:request_id", postRealEstateTypes);
|
||||
app.post("/vrstanekretnine", postRealEstateTypes);
|
||||
|
||||
app.get('/grad/:request_id', getRegion);
|
||||
app.post('/grad/:request_id', postRegion);
|
||||
app.get("/grad/:request_id", getRegion);
|
||||
app.post("/grad/:request_id", postRegion);
|
||||
|
||||
app.get('/mjesto/:request_id', getMunicipality);
|
||||
app.post('/mjesto/:request_id', postMunicipality);
|
||||
app.get("/mjesto/:request_id", getMunicipality);
|
||||
app.post("/mjesto/:request_id", postMunicipality);
|
||||
|
||||
app.get('/naselje/:request_id/:municipality', getNeighborhood);
|
||||
app.post('/naselje/:request_id/:municipality', postNeighborhood);
|
||||
app.get("/naselje/:request_id/:municipality", getNeighborhood);
|
||||
app.post("/naselje/:request_id/:municipality", postNeighborhood);
|
||||
|
||||
app.get('/povrsina/:request_id', getSize);
|
||||
app.post('/povrsina/:request_id', postSize);
|
||||
app.get("/povrsina/:request_id", getSize);
|
||||
app.post("/povrsina/:request_id", postSize);
|
||||
|
||||
app.get('/okucnica/:request_id', getGardenSize);
|
||||
app.post('/okucnica/:request_id', postGardenSize);
|
||||
app.get("/okucnica/:request_id", getGardenSize);
|
||||
app.post("/okucnica/:request_id", postGardenSize);
|
||||
|
||||
app.get('/cijena/:request_id', getPrice);
|
||||
app.post('/cijena/:request_id', postPrice);
|
||||
app.get("/cijena/:request_id", getPrice);
|
||||
app.post("/cijena/:request_id", postPrice);
|
||||
|
||||
app.get('/pregled/:request_id', getQueryReview);
|
||||
app.post('/pregled/:request_id', postQueryReview);
|
||||
app.get("/pregled/:request_id", getQueryReview);
|
||||
app.post("/pregled/:request_id", postQueryReview);
|
||||
|
||||
app.get('/posalji/:request_id', getQuerySubmit);
|
||||
app.post('/posalji/:request_id', postQuerySubmit);
|
||||
app.get("/posalji/:request_id", getQuerySubmit);
|
||||
app.post("/posalji/:request_id", postQuerySubmit);
|
||||
|
||||
app.get('/odjava/:request_id', getUnsubscribe);
|
||||
app.get("/odjava/:request_id", getUnsubscribe);
|
||||
|
||||
app.get('/ponovo', getGoAgain);
|
||||
app.get("/ponovo", getGoAgain);
|
||||
|
||||
app.get('/nekretnine/:request_id', getRealEstates);
|
||||
app.get("/nekretnine/:request_id", getRealEstates);
|
||||
|
||||
app.use('/assets', express.static('./app/public'));
|
||||
app.get("/redirect/:id", redirect);
|
||||
|
||||
app.use("/assets", express.static("./app/public"));
|
||||
|
||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
||||
|
||||
var rule = new schedule.RecurrenceRule();
|
||||
rule.seccond = 1;
|
||||
schedule.scheduleJob(rule, async function () {
|
||||
console.log(new Date(), 'Crawler service started');
|
||||
await crawlAll();
|
||||
console.log(new Date(), 'Crawler service finished, starting Notification service');
|
||||
await processNotifications();
|
||||
console.log(new Date(), 'Notification service finished');
|
||||
});
|
||||
|
||||
/**
|
||||
* Add flat method to Array
|
||||
*/
|
||||
Object.defineProperty(Array.prototype, 'flat', {
|
||||
value: function(depth = 1) {
|
||||
return this.reduce(function (flat, toFlatten) {
|
||||
return flat.concat((Array.isArray(toFlatten) && (depth>1)) ? toFlatten.flat(depth-1) : toFlatten);
|
||||
}, []);
|
||||
}
|
||||
rule.seccond = 1;
|
||||
schedule.scheduleJob(rule, async function() {
|
||||
console.log(new Date(), "Crawler service started");
|
||||
await crawlAll();
|
||||
console.log(
|
||||
new Date(),
|
||||
"Crawler service finished, starting Notification service"
|
||||
);
|
||||
await processNotifications();
|
||||
console.log(new Date(), "Notification service finished");
|
||||
});
|
||||
|
||||
/**
|
||||
* Add flat method to Array
|
||||
*/
|
||||
Object.defineProperty(Array.prototype, "flat", {
|
||||
value: function(depth = 1) {
|
||||
return this.reduce(function(flat, toFlatten) {
|
||||
return flat.concat(
|
||||
Array.isArray(toFlatten) && depth > 1
|
||||
? toFlatten.flat(depth - 1)
|
||||
: toFlatten
|
||||
);
|
||||
}, []);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user