Improved npm start scripts, added script to use server in production mode, without SSL certificate.
This commit is contained in:
+4
-2
@@ -5,12 +5,14 @@
|
||||
"license": "",
|
||||
"scripts": {
|
||||
"server": "live-server public/",
|
||||
"build": "cross-env NODE_ENV=production webpack -p --env production",
|
||||
"build:no-ssl": "cross-env NODE_ENV=production-no-ssl webpack -p --env production-no-ssl",
|
||||
"build:dev": "webpack",
|
||||
"build:prod": "cross-env NODE_ENV=production webpack -p --env production",
|
||||
"dev-server": "webpack-dev-server",
|
||||
"test": "cross-env NODE_ENV=test env-cmd -f ./config/test.env jest --config=jest.config.json --watchAll --runInBand",
|
||||
"start:dev": "env-cmd -f ./config/dev.env node server/serverStart.js",
|
||||
"start": "env-cmd -f ./config/prod.env node server/serverStart.js",
|
||||
"start": "cross-env NODE_ENV=production env-cmd -f ./config/prod.env node server/serverStart.js --env production",
|
||||
"start:no-ssl": "cross-env NODE_ENV=production-no-ssl env-cmd -f ./config/prod.env node server/serverStart.js --env production-no-ssl",
|
||||
"clean-database": "env-cmd -f ./config/prod.env node serverUtils/cleanDatabase.js",
|
||||
"clean-database:dev": "env-cmd -f ./config/dev.env node serverUtils/cleanDatabase.js",
|
||||
"backup-database": "env-cmd -f ./config/prod.env node serverUtils/backupDatabase.js",
|
||||
|
||||
+18
-10
@@ -12,23 +12,31 @@ const fs = require("fs");
|
||||
const helmet = require("helmet");
|
||||
const busboy = require("connect-busboy")
|
||||
const compression = require("compression");
|
||||
const http = require("http");
|
||||
|
||||
|
||||
const cert = fs.readFileSync("certificate.crt")
|
||||
const ca = fs.readFileSync("certificate.ca-bundle");
|
||||
const key = fs.readFileSync("certificate.key");
|
||||
let server;
|
||||
let serverHttps;
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
|
||||
const cert = fs.readFileSync("certificate.crt")
|
||||
const ca = fs.readFileSync("certificate.ca-bundle");
|
||||
const key = fs.readFileSync("certificate.key");
|
||||
|
||||
|
||||
const options = {
|
||||
cert,
|
||||
ca,
|
||||
key
|
||||
const options = {
|
||||
cert,
|
||||
ca,
|
||||
key
|
||||
}
|
||||
|
||||
serverHttps = https.createServer( options, app );
|
||||
}
|
||||
|
||||
const http = require("http")
|
||||
|
||||
const server = http.createServer(app);
|
||||
const serverHttps = https.createServer( options, app );
|
||||
server = http.createServer(app);
|
||||
|
||||
|
||||
|
||||
require("../src/db/mongoose")
|
||||
|
||||
@@ -16,6 +16,14 @@ const serverStart = async() => {
|
||||
console.log( 'Https Server Running On Port:', process.env.HTTPS_PORT);
|
||||
} );
|
||||
|
||||
} else if (process.env.NODE_ENV === 'production-no-ssl') {
|
||||
|
||||
const server = require("./server");
|
||||
|
||||
server.listen(process.env.HTTP_PORT,process.env.URL, () => {
|
||||
console.log("Http Server (No-SSL) Running On Port:", process.env.HTTP_PORT);
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
const server = require("./server");
|
||||
|
||||
+2
-1
@@ -24,7 +24,8 @@ if (process.env.NODE_ENV === "test") {
|
||||
|
||||
module.exports = (env) => {
|
||||
|
||||
const isProduction = env === "production"
|
||||
const isProduction = (env === "production" || env === "production-no-ssl")
|
||||
console.log("is prod", isProduction);
|
||||
|
||||
const CSSExtract = new MiniCssExtractPlugin({ filename: 'styles.css' });
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user