Removed hash route prefix from backend.
Also linting.
This commit is contained in:
@@ -18,8 +18,9 @@ async function sendInitialMessageToWinners(winners) {
|
||||
|
||||
const body = {
|
||||
sender: "Vinlottis",
|
||||
message: "Gratulerer som vinner av vinlottisen! Du vil snart få en SMS med oppdatering om hvordan gangen går!",
|
||||
recipients: numbers
|
||||
message:
|
||||
"Gratulerer som vinner av vinlottisen! Du vil snart få en SMS med oppdatering om hvordan gangen går!",
|
||||
recipients: numbers,
|
||||
};
|
||||
|
||||
return gatewayRequest(body);
|
||||
@@ -31,7 +32,7 @@ async function sendPrizeSelectionLink(winner) {
|
||||
await winner.save();
|
||||
|
||||
const { id, name, phoneNumber } = winner;
|
||||
const url = new URL(`/#/winner/${id}`, "https://lottis.vin");
|
||||
const url = new URL(`/winner/${id}`, `https://${config.domain}`);
|
||||
const message = `Gratulerer som heldig vinner av vinlotteriet ${name}! Her er linken for \
|
||||
å velge hva slags vin du vil ha, du har 10 minutter på å velge ut noe før du blir lagt bakerst \
|
||||
i køen. ${url.href}. (Hvis den siden kommer opp som tom må du prøve å refreshe siden noen ganger.`;
|
||||
@@ -75,7 +76,7 @@ async function sendMessageToNumber(phoneNumber, message) {
|
||||
const body = {
|
||||
sender: "Vinlottis",
|
||||
message: message,
|
||||
recipients: [{ msisdn: `47${phoneNumber}` }]
|
||||
recipients: [{ msisdn: `47${phoneNumber}` }],
|
||||
};
|
||||
|
||||
return gatewayRequest(body);
|
||||
@@ -89,8 +90,8 @@ async function gatewayRequest(body) {
|
||||
path: `/rest/mtsms?token=${config.gatewayToken}`,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(options, res => {
|
||||
@@ -128,5 +129,5 @@ module.exports = {
|
||||
sendPrizeSelectionLink,
|
||||
sendWineConfirmation,
|
||||
sendLastWinnerMessage,
|
||||
sendWineSelectMessageTooLate
|
||||
sendWineSelectMessageTooLate,
|
||||
};
|
||||
|
||||
12
server.js
12
server.js
@@ -23,7 +23,7 @@ mongoose
|
||||
useCreateIndex: true,
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
serverSelectionTimeoutMS: 10000 // initial connection timeout
|
||||
serverSelectionTimeoutMS: 10000, // initial connection timeout
|
||||
})
|
||||
.then(_ => console.log("Mongodb connection established!"))
|
||||
.catch(err => {
|
||||
@@ -59,8 +59,8 @@ app.use(
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: new MongoStore({
|
||||
mongooseConnection: mongoose.connection
|
||||
})
|
||||
mongooseConnection: mongoose.connection,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -84,10 +84,6 @@ app.use("/service-worker.js", express.static(path.join(__dirname, "public/sw/ser
|
||||
// api endpoints
|
||||
app.use("/api/", apiRouter);
|
||||
|
||||
// redirects
|
||||
app.get("/dagens", (req, res) => res.redirect("/#/dagens"));
|
||||
app.get("/winner/:id", (req, res) => res.redirect("/#/winner/" + req.params.id));
|
||||
|
||||
// push-notifications
|
||||
app.use("/subscription", subscriptionApi);
|
||||
|
||||
@@ -95,4 +91,4 @@ app.use("/subscription", subscriptionApi);
|
||||
app.use("/", (req, res) => res.sendFile(path.join(__dirname + "/public/dist/index.html")));
|
||||
|
||||
server.listen(30030);
|
||||
console.log("Server listening on :30030")
|
||||
console.log("Server listening on :30030");
|
||||
|
||||
Reference in New Issue
Block a user