Not crashing without configs anymore

This commit is contained in:
Kasper Rynning-Tønnesen
2020-03-04 08:52:57 +01:00
parent f28311a709
commit 72d67d862d
5 changed files with 21 additions and 7 deletions

View File

@@ -9,10 +9,10 @@ mongoose.connect("mongodb://localhost:27017/vinlottis", {
useNewUrlParser: true
});
const config = require(path.join(__dirname + "/../config/env/push"));
const config = require(path.join(__dirname + "/../config/defaults/push"));
const Subscription = require(path.join(__dirname + "/../schemas/Subscription"));
const lotteryConfig = require(path.join(
__dirname + "/../config/env/lottery.config"
__dirname + "/../config/defaults/lottery"
));
router.use((req, res, next) => {

View File

@@ -0,0 +1,15 @@
try {
module.exports = require("../env/lottery.config");
} catch (e) {
console.error(
"You haven't defined lottery-configs, you sure you want to continue without them?"
);
module.exports = {
name: "NAME MISSING",
phone: "PHONE_MISSING",
price: 10,
message: "INSERT MESSAGE",
date: 5,
hours: 15
};
}

View File

@@ -1,5 +1,5 @@
try {
module.exports = require("./push.config");
module.exports = require("../env/push.config");
} catch (e) {
console.error(
"You haven't defined push-parameters, you sure you want to continue without them?"

View File

@@ -42,7 +42,7 @@ const ServiceWorkerConfig = {
plugins: [
new webpack.DefinePlugin({
__DATE__: new Date().getTime(),
__PUBLICKEY__: JSON.stringify(require("./env/push").publicKey)
__PUBLICKEY__: JSON.stringify(require("./defaults/push").publicKey)
})
]
};

View File

@@ -1,10 +1,9 @@
"use strict";
const env = require("./env/lottery.config.js");
const env = require("./defaults/lottery");
const webpack = require("webpack");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
const HtmlPlugin = require("html-webpack-plugin");
const helpers = require("./helpers");
const webpackConfig = function(isDev) {
@@ -79,7 +78,7 @@ const webpackConfig = function(isDev) {
__MESSAGE__: JSON.stringify(env.message),
__DATE__: env.date,
__HOURS__: env.hours,
__PUSHENABLED__: JSON.stringify(require("./env/push") != false)
__PUSHENABLED__: JSON.stringify(require("./defaults/push") != false)
})
]
};