change how APP_URL is used, use JS templating string
This commit is contained in:
9
app/config/appConfig.js
Normal file
9
app/config/appConfig.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const APP_PORT = process.env.APP_PORT || 5000;
|
||||||
|
const APP_BASE_URL = process.env.APP_BASE_URL || "http://localhost";
|
||||||
|
|
||||||
|
const APP_URL = `${APP_BASE_URL}:${APP_PORT}`;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
APP_PORT,
|
||||||
|
APP_URL
|
||||||
|
};
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
const { APP_URL } = require("../config/appConfig");
|
||||||
const { getRealEstateTypeEnum } = require("./enums");
|
const { getRealEstateTypeEnum } = require("./enums");
|
||||||
const { getRegionName, getMunicipalityName } = require("./codes");
|
const { getRegionName, getMunicipalityName } = require("./codes");
|
||||||
const { allRERequestByUiid } = require("./db/dbHelper");
|
const { allRERequestByUiid } = require("./db/dbHelper");
|
||||||
@@ -82,15 +83,15 @@ const getGreetingsEmailHTML = realestateRequest => {
|
|||||||
<div>
|
<div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div><strong> Ako želis prestati dobijati obavještenja za ovu pretragu klikni ${
|
<div><strong> Ako želis prestati dobijati obavještenja za ovu pretragu klikni ${APP_URL}/odjava/${
|
||||||
process.env.APP_URL
|
realestateRequest.uniqueId
|
||||||
}/odjava/${realestateRequest.uniqueId} </strong></div>
|
} </strong></div>
|
||||||
<div><strong>Ako želiš promijeniti uslove pretrage klikni ${
|
<div><strong>Ako želiš promijeniti uslove pretrage klikni ${APP_URL}/pregled/${
|
||||||
process.env.APP_URL
|
realestateRequest.uniqueId
|
||||||
}/pregled/${realestateRequest.uniqueId} </strong></div>
|
} </strong></div>
|
||||||
<h4> Tvoj,
|
<h4> Tvoj,
|
||||||
Javimi tim.
|
Javimi tim.
|
||||||
</h4>`;
|
</h4>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGreetingsEmaiTextVersion = realestateRequest => {
|
const getGreetingsEmaiTextVersion = realestateRequest => {
|
||||||
@@ -98,40 +99,27 @@ const getGreetingsEmaiTextVersion = realestateRequest => {
|
|||||||
realestateRequest.realEstateType
|
realestateRequest.realEstateType
|
||||||
);
|
);
|
||||||
const gardenSize = realEstateType.hasGardenSize
|
const gardenSize = realEstateType.hasGardenSize
|
||||||
? "Kvadratura okućnice od " +
|
? `Kvadratura okućnice od ${realestateRequest.gardenSizeMin} do ${realestateRequest.gardenSizeMax}`
|
||||||
realestateRequest.gardenSizeMin +
|
|
||||||
" do " +
|
|
||||||
realestateRequest.gardenSizeMax
|
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
const text =
|
const text = `Zdravo, \n Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima
|
||||||
"Zdravo, \n Naručio/la si da ti javimo ako se nekretnina pojavi u oglasima \n Ovo je tražena nekretnina: \n , Tip nekretnine: " +
|
\n Ovo je tražena nekretnina: \n , Tip nekretnine: ${
|
||||||
realestateRequest.realEstateType +
|
realestateRequest.realEstateType
|
||||||
"\n Područje" +
|
} \n Područje ${getRegionName(
|
||||||
getRegionName(realestateRequest.region) +
|
realestateRequest.region
|
||||||
"\n Mjesto " +
|
)} \n Mjesto ${getMunicipalityName(
|
||||||
getMunicipalityName(
|
realestateRequest.region,
|
||||||
realestateRequest.region,
|
realestateRequest.municipality
|
||||||
realestateRequest.municipality
|
)}
|
||||||
) +
|
\n Kvadratura nekretnine Od ${realestateRequest.sizeMin} do ${
|
||||||
"\n Kvadratura nekretnine Od " +
|
realestateRequest.sizeMaX
|
||||||
realestateRequest.sizeMin +
|
} ${gardenSize} \n Cijena od ${realestateRequest.priceMin} do ${
|
||||||
" do " +
|
realestateRequest.priceMax
|
||||||
realestateRequest.sizeMaX +
|
} \n Ako želis prestati dobijati obavještenja za ovu pretragu klikni
|
||||||
+gardenSize;
|
${APP_URL}/odjava/${
|
||||||
"\n Cijena od " +
|
realestateRequest.uniqueId
|
||||||
realestateRequest.priceMin +
|
}\n Ako želiš promijeniti uslove pretrage klikni
|
||||||
" do " +
|
${APP_URL}/odpregled/${realestateRequest.uniqueId}\n Tvoj,\n Javimi tim`;
|
||||||
realestateRequest.priceMax +
|
|
||||||
"\n Ako želis prestati dobijati obavještenja za ovu pretragu klikni" +
|
|
||||||
process.env.APP_URL +
|
|
||||||
"/odjava/" +
|
|
||||||
realestateRequest.uniqueId +
|
|
||||||
"\n Ako želiš promijeniti uslove pretrage klikni " +
|
|
||||||
process.env.APP_URL +
|
|
||||||
"/odpregled/" +
|
|
||||||
realestateRequest.uniqueId +
|
|
||||||
"\n Tvoj,\n Javimi tim";
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
@@ -162,7 +150,7 @@ const sendBulkEmail = async marketAlerts => {
|
|||||||
realEstateType: RERequest.realEstateType,
|
realEstateType: RERequest.realEstateType,
|
||||||
region: RERequest.region,
|
region: RERequest.region,
|
||||||
municipality: RERequest.municipality,
|
municipality: RERequest.municipality,
|
||||||
requestUrl: `${process.env.APP_URL}/nekretnine/${RERequest.uniqueId}`
|
requestUrl: `${APP_URL}/nekretnine/${RERequest.uniqueId}`
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -233,8 +221,7 @@ const sendBulkEmail = async marketAlerts => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectUrl = marketAlertId =>
|
const redirectUrl = marketAlertId => `${APP_URL}/redirect/${marketAlertId}`;
|
||||||
`${process.env.APP_URL}/redirect/${marketAlertId}`;
|
|
||||||
const toAWSArray = urlArray => {
|
const toAWSArray = urlArray => {
|
||||||
let arrayString = "";
|
let arrayString = "";
|
||||||
urlArray.forEach(element => {
|
urlArray.forEach(element => {
|
||||||
@@ -247,11 +234,11 @@ const toAWSArray = urlArray => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getNotificationEmailHtml = () => {
|
const getNotificationEmailHtml = () => {
|
||||||
return `<h2> Zdravo,
|
return `<h2> Zdravo,
|
||||||
Pronašli smo nekretninu koju ste tražili. </h2>
|
Pronašli smo nekretninu koju ste tražili. </h2>
|
||||||
<h3> Ovo su tražene nekretnine: </h3>
|
<h3> Ovo su tražene nekretnine: </h3>
|
||||||
<div>
|
<div>
|
||||||
<div>{{#each marketAlertUrl}}<li><a href="{{url}}">{{title}}</a></li><br />{{/each}}<div/>
|
<div>{{#each marketAlertUrl}}<li><a href="{{url}}">{{title}}</a></li><br />{{/each}}<div/>
|
||||||
<div/>
|
<div/>
|
||||||
<div>Kompletan spisak nekretnina možete pegledati ovdije: <a href="{{requestUrl}}">Nekretnine</a> <div>
|
<div>Kompletan spisak nekretnina možete pegledati ovdije: <a href="{{requestUrl}}">Nekretnine</a> <div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ DB_PORT=Database port
|
|||||||
|
|
||||||
SEQUELIZE_LOGGING=0- no sequelize logging, 1- log to the console
|
SEQUELIZE_LOGGING=0- no sequelize logging, 1- log to the console
|
||||||
|
|
||||||
|
APP_PORT=Port for the app, defaults to 5000
|
||||||
|
APP_BASE_URL=base url for the app
|
||||||
|
|
||||||
AMAZON_ACCES_KEY_ID=(your-key-here)
|
AMAZON_ACCES_KEY_ID=(your-key-here)
|
||||||
AMAZON_SECRET_ACCESS_KEY=(your-key-here)
|
AMAZON_SECRET_ACCESS_KEY=(your-key-here)
|
||||||
AMAZON_REGION=eu-west-1
|
AMAZON_REGION=eu-west-1
|
||||||
|
|||||||
7
index.js
7
index.js
@@ -1,4 +1,5 @@
|
|||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
const { APP_PORT } = require("./app/config/appConfig");
|
||||||
|
|
||||||
const welcome = require("./app/controllers/welcome").getWelcome;
|
const welcome = require("./app/controllers/welcome").getWelcome;
|
||||||
const {
|
const {
|
||||||
@@ -50,8 +51,6 @@ const app = express();
|
|||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
const port = process.env.PORT || 5000;
|
|
||||||
|
|
||||||
app.set("views", path.join(__dirname, "/app/views"));
|
app.set("views", path.join(__dirname, "/app/views"));
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
app.use(layout());
|
app.use(layout());
|
||||||
@@ -182,7 +181,9 @@ app.get("/redirect/:id", redirect);
|
|||||||
|
|
||||||
app.use("/assets", express.static("./app/public"));
|
app.use("/assets", express.static("./app/public"));
|
||||||
|
|
||||||
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
|
app.listen(APP_PORT, () =>
|
||||||
|
console.log(`Example app listening on port ${APP_PORT}!`)
|
||||||
|
);
|
||||||
|
|
||||||
var rule = new schedule.RecurrenceRule();
|
var rule = new schedule.RecurrenceRule();
|
||||||
rule.seccond = 1;
|
rule.seccond = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user