Refactor/Project structure #67

Merged
KevinMidboe merged 56 commits from refactor/project-structure into master 2020-12-10 22:20:38 +00:00
2 changed files with 6 additions and 11 deletions
Showing only changes of commit 51e11d0df0 - Show all commits

View File

@@ -75,15 +75,10 @@ app.use("/api/", apiRouter);
app.get("/dagens", (req, res) => res.redirect("/#/dagens")); app.get("/dagens", (req, res) => res.redirect("/#/dagens"));
app.get("/winner/:id", (req, res) => res.redirect("/#/winner/" + req.params.id)); app.get("/winner/:id", (req, res) => res.redirect("/#/winner/" + req.params.id));
// push-notifications & service workers // push-notifications
app.use("/subscription", subscriptionApi); app.use("/subscription", subscriptionApi);
app.use("/service-worker.js", function(req, res) {
if (process.env.NODE_ENV == "development") {
return res.end(); // cancel serving service worker if localhost
}
res.sendFile(path.join(__dirname, "src/serviceWorker.js"));
});
app.use("/", (req, res) => res.sendFile(path.join(__dirname + "/dist/index.html"))); // No other route defined, return index file
app.use("/", (req, res) => res.sendFile(path.join(__dirname + "/public/dist/index.html")));
server.listen(30030); server.listen(30030);

View File

@@ -9,11 +9,11 @@ var serviceWorkerRegistrationMixin = {
localStorage.removeItem("push"); localStorage.removeItem("push");
} }
} }
this.registerPushListener(); if (window.location.href.includes('localhost')) {
this.registerServiceWorker();
if (__ENV__ == "development") {
console.info("Service worker manually disabled while on localhost.") console.info("Service worker manually disabled while on localhost.")
} else { } else {
this.registerPushListener();
this.registerServiceWorker();
} }
}, },
methods: { methods: {