Skip to content

A starter project for dev and production builds of Webpack, React, and Redux.

License

Notifications You must be signed in to change notification settings

toddnagel/Ghadyani-Framework-Webpack-React-Redux

 
 

Repository files navigation

Ghadyani Framework for Webpack, React, and Redux

Codeship Status for Sawtaytoes/Ghadyani-Framework-Webpack-React-Redux

Prerequisites

Required

Optional

  • MailDev Local Mail Server for Testing Email

Setup

Config Settings

Default configs are configSettings.js. Here's an example of what defaults might look like

env: 'production',                            // Can be 'development' or 'production'.

//- Server
protocol: 'http',                             // Using `https` requires valid certificates.
hostname: '0.0.0.0',                          // Can be 0.0.0.0 for binding to all ports.
port: 3000,                                   // Port of webserver.
// proxyPort: 3001,                           // Optional. Will be `port + 1` if not defined.

//- Testing
testsPath: '/tests',                          // Path used when performing unit-tests

//- Email Submission
mailSendPath: '/contact/send',                // Path that's used when doing a POST to send mail.
mailOptions: {                                // Options for Nodemailer.
	from: 'Fake User <[email protected]>', // When sending mail, this appears in the `FROM` field
},
smtpCredentials: {                            // Configuration for a local maildev server.
	host: 'localhost',
	port: 1025,
	tls: {
		rejectUnauthorized: false,
	}
}

To override these configs, either setup Node env vars such as: NODE_ENV, PROTOCOL, HOSTNAME, PORT, etc or create a ./server/configs/config.js file and have it return an object with overrides like so:

module.exports = {
	env: 'development',
	protocol: 'https',
	port: 443,
}

SMTP Configuration

Example using maildev (npm i -g maildev):

smtpCredentials: {
	host: 'localhost',
	port: 1025,
	tls: { rejectUnauthorized: false },
}

Example gmail.com string:

smtpCredentials: 'smtps://user%40gmail.com:[email protected]'

Start the local catch-all SMTP server using the command maildev.

Web Server Setup

Development: Local

yarn start

OR

bash local.sh

OR

node index.js

Production: Hosted VPS

Using PM2

Start the Server

Start a single server for testing:

bash server.sh

Start a cluster of 3 servers for load balancing in production:

bash server.sh 3

The number 3 can be replaced with any number. The default is 0: equal to the number of CPU cores.

Update from Git and Restart

bash update.sh

If you update the update.sh file, make sure to run git pull prior to running the update script.

Stop the Server

bash stopServer.sh

Create SSL Cert

Make sure to run this command to upgrade pip before starting:

pip install --upgrade pip

Optionally, you can upgrade Let's Encrypt:

cd /usr/share/letsencrypt/
git pull

Replace SERVER_NAME with the website address.

service nginx stop

/usr/share/letsencrypt/letsencrypt-auto certonly \
-a standalone \
-d www.SERVER_NAME \
-d SERVER_NAME \
--server https://acme-v01.api.letsencrypt.org/directory

service nginx start

Or try this experimental approach:

/usr/share/letsencrypt/letsencrypt-auto certonly \
-a nginx \
-d www.SERVER_NAME \
-d SERVER_NAME \
--server https://acme-v01.api.letsencrypt.org/directory

When running the Let's Encrypt with, it requires installing the NGINX plugin:

cd /usr/share/letsencrypt/
~/.local/share/letsencrypt/bin/pip install -U letsencrypt-nginx

Let's Encrypt allows renewing using:

/usr/share/letsencrypt/letsencrypt-auto renew

Create & Update Dev SSL Certs

For ServiceWorker compatibility, update or use these certs along with https in network-protocol.

Using ZeroSSL and their FREE SSL Certificate Wizard:

  • Files are located in conf/

Linting

Install packages globally for Sublime Text's SublimeLinter-contrib-eslint plugin.

npm i -g babel-eslint eslint-plugin-react

About

A starter project for dev and production builds of Webpack, React, and Redux.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.9%
  • CSS 7.4%
  • Shell 0.7%