Giter VIP home page Giter VIP logo

tmpl8-react's Introduction

tmpl8-react

A project seeder for React that is used as a submodule for the main tmpl8 project. Feel free to use it for your own projects!

Build Status

Get Started

Install Dependencies

Clone this repository and run:

# yarn install
# bower install

You should be able to start the application with:

# npm start

Run Application

Two environments are provisioned: dev and prd for developmnt and production respectively. You can set them using the NODE_ENV variable before running npm start:

# NODE_ENV=dev npm start

This runs the application in dev.

# NODE_ENV=prd npm start

This runs the application in prd.

Deploy Application

We can deploy via PM2 or Docker. For deployment in dev for PM2 and Docker respectively:

# npm run deploy-pm2-dev
# npm run deploy-docker-dev

For deployment using NODE_ENV=prd, the commands for PM2 and Docker respectively are:

# npm run deploy-pm2-prd
# npm run deploy-docker-prd

The relevant files can be found in ./scripts under the same name as the npm command.

Development

Development Environment

The development environment includes tools that help with developer productivity such as:

  • Application hot-reloading
  • Server live-reloading

Application hot-reloading is done via Webpack and server live-reloading is done by launching your application using Nodemon instead of Node.

Testing

Unit Tests

Testing for the front-end (React.js) is done using Karma. Run the tests using:

# npm run karma

For monitoring, there's also a watch command:

# npm run karma-watch

The relevant file to modify test conditions are at: ./config/karma.config.js.

Integration & System Tests

Testing for the back-end (Node.js) is done using Mocha. Run the tests using:

# npm run mocha

For monitoring, there's also a watch command:

# npm run mocha-watch

Security Scanning

Security scanning is done on the node_modules dependencies folder using nsp. To run it:

# npm run nsp

Code Quality

Code quality is maintained using ESLint. Run it with:

# npm run eslint

To automatically fix any errors that ESLint encounters, use:

# npm run esint-fix

Building

After development is complete, you may build your application by running:

# npm run build

After building, you may wish to test if your application using:

# npm run unbuild
# yarn install --production
# bower install --production
# NODE_ENV=prd npm start

The relevant file for altering the build can be found at ./config/webpack.config.js.

Build Size Debugging

When building, should you wish to debug your output files, we include Webpack Bundle Analyzer which helps to visualise the file sizes of your build. Run it using:

# WEBPACK_BUNDLE_ANALYZER=1 npm run build

Configuration

Environment Variables

LOG_PATH

This defines the path where logs will be written to.

NODE_ENV

This defines the environment Node will run in. Two environments are available: dev and prd.

PORT

This defines the port which the application will listen on. By default, it is 3333 for dev and 3334 for prd.

Deployment

On Virtual Machines

This package is prepared for running on the PM2 process manager. The relevant configuration can be found in ./ecosystem.js and the command to start this application using PM2 is:

# npm deploy-pm2

The relevant script can be found at ./scripts/.deploy-pm2.

On Containers

We can also use Docker for deployment. You may run the deployments in dev and prd by using:

# npm run deploy-docker-dev

and

# npm run deploy-docker-prd

Both commands will run in the foreground. To run them in the background, run:

# npm run deploy-docker-dev -- -d

and

# npm run deploy-docker-prd -- -d

The relevant scripts can be found at ./scripts/.deploy-docker-dev and ./scripts/.deploy-docker-prd.

Logging

Logging is handled by Winston and is available at both the process level and the request level. The request level is handled by Morgan. The relevant files can be found at ./config/logger.config.js and ./index.js.

Contributing

Guiding Principles

This seeder package was created as a seeder which accounts for deployment from the start. As a rule of thumb, the focus of this seeder project is on:

  • Ease of Development
  • Ease of Quality
  • Ease of Deployment

The 12-factor app is a good starting resource for principles implemented here. Read about it at https://12factor.net/.

Contribution Considerations

This package is used as a submodule in the tmpl8 seeder application, and should maintain compatibitliy with it.

Methodology

Fork this repository, make your changes, add relevant tests (if any) and raise a Merge Request.

tmpl8-react's People

Contributors

zephinzer avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.