Skip to content
This repository has been archived by the owner on Dec 8, 2019. It is now read-only.

A playground for me to test out React components with the Ghadyani Framework

License

Notifications You must be signed in to change notification settings

Sawtaytoes/Ghadyani-Framework-Playground

Repository files navigation

Ghadyani Framework Playground

Playground for testing React components with various tooling using the Ghadyani Framework for Webpack, React, and 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 <fake.user@example.com>', // 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:pass@smtp.gmail.com'

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