Removed hash route prefix from backend.
Also linting.
This commit is contained in:
@@ -18,8 +18,9 @@ async function sendInitialMessageToWinners(winners) {
|
|||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
sender: "Vinlottis",
|
sender: "Vinlottis",
|
||||||
message: "Gratulerer som vinner av vinlottisen! Du vil snart få en SMS med oppdatering om hvordan gangen går!",
|
message:
|
||||||
recipients: numbers
|
"Gratulerer som vinner av vinlottisen! Du vil snart få en SMS med oppdatering om hvordan gangen går!",
|
||||||
|
recipients: numbers,
|
||||||
};
|
};
|
||||||
|
|
||||||
return gatewayRequest(body);
|
return gatewayRequest(body);
|
||||||
@@ -31,7 +32,7 @@ async function sendPrizeSelectionLink(winner) {
|
|||||||
await winner.save();
|
await winner.save();
|
||||||
|
|
||||||
const { id, name, phoneNumber } = winner;
|
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 \
|
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 \
|
å 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.`;
|
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 = {
|
const body = {
|
||||||
sender: "Vinlottis",
|
sender: "Vinlottis",
|
||||||
message: message,
|
message: message,
|
||||||
recipients: [{ msisdn: `47${phoneNumber}` }]
|
recipients: [{ msisdn: `47${phoneNumber}` }],
|
||||||
};
|
};
|
||||||
|
|
||||||
return gatewayRequest(body);
|
return gatewayRequest(body);
|
||||||
@@ -89,8 +90,8 @@ async function gatewayRequest(body) {
|
|||||||
path: `/rest/mtsms?token=${config.gatewayToken}`,
|
path: `/rest/mtsms?token=${config.gatewayToken}`,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json",
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const req = https.request(options, res => {
|
const req = https.request(options, res => {
|
||||||
@@ -128,5 +129,5 @@ module.exports = {
|
|||||||
sendPrizeSelectionLink,
|
sendPrizeSelectionLink,
|
||||||
sendWineConfirmation,
|
sendWineConfirmation,
|
||||||
sendLastWinnerMessage,
|
sendLastWinnerMessage,
|
||||||
sendWineSelectMessageTooLate
|
sendWineSelectMessageTooLate,
|
||||||
};
|
};
|
||||||
|
|||||||
12
server.js
12
server.js
@@ -23,7 +23,7 @@ mongoose
|
|||||||
useCreateIndex: true,
|
useCreateIndex: true,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: true,
|
useUnifiedTopology: true,
|
||||||
serverSelectionTimeoutMS: 10000 // initial connection timeout
|
serverSelectionTimeoutMS: 10000, // initial connection timeout
|
||||||
})
|
})
|
||||||
.then(_ => console.log("Mongodb connection established!"))
|
.then(_ => console.log("Mongodb connection established!"))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -59,8 +59,8 @@ app.use(
|
|||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
store: new MongoStore({
|
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
|
// api endpoints
|
||||||
app.use("/api/", apiRouter);
|
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
|
// push-notifications
|
||||||
app.use("/subscription", subscriptionApi);
|
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")));
|
app.use("/", (req, res) => res.sendFile(path.join(__dirname + "/public/dist/index.html")));
|
||||||
|
|
||||||
server.listen(30030);
|
server.listen(30030);
|
||||||
console.log("Server listening on :30030")
|
console.log("Server listening on :30030");
|
||||||
|
|||||||
Reference in New Issue
Block a user