Boilerplate app to get you up and running with Hapi, HTTP/2, Web Sockets and React.
Demo can be found here
I've written a blog article detailing the steps I've gone through to create. Also the good 😇, the bad 👿 and the ugly ☠️.
Assuming you are on Mac OS 🍏 and Node 8.9.4 or higher installed. Not tested on any other OS.
As this boilerplate uses HTTPS, you will need to create a local SSL (Secure Socket Layer) certificate and key. If you are not familar with creating an SSL certificate on your Mac, plaese look here.
By following the below steps you will run an NPM script npm run createCertificate, which will create an SSL certficate and key for you. It will also move them to the correct folder, to make life as painless as possible for you. In the project there is a folder named ssl, in here I have created a shell script named createCerts.sh. This is where the magic (told myself this) happens. You are more than welcome to delve in here and see the dark arts of shell scripting if you are unfamilar with this.
In the terminal run the following: -
git clone git@github.com:blairg/hapi-socket-react-boilerplate.gitcd hapi-socket-react-boilerplate- Create certificate for HTTPS
npm run createCertificate. Fill in the questions when asked. Can be fictitious values. npm inpm run dev- In your browser go to
https://localhost:3000/index(add security exception rule for local cert). Look here for Chrome chrome://flags/#allow-insecure-localhost. - 👏
Ensure you have created the cert and key as per the previous step.
Assuming you have cloned the repo and installed the packages. Also, that you have Docker and Docker Compose installed too. In the terminal do the following, in the root of the directory you cloned the repo too: -
- Create certificate for HTTPS
npm run createCertificate. Details are all optional. - Create an
.envfile, this can be blank as the Dockerfile has default values set. docker-compose up- In your browser go to
https://localhost:3000/index(add security exception rule for local cert).
Following options: -
- To just run the unit tests ->
npm run test - To run tests with coverage (Istanbul) ->
npm run test:coverage. This will output tocoveragefolder. Locate theindex.htmlin here and open in your browser. - To watch tests for changes ->
npm run test:watch - In VS Code you have 2 debug options avaiable for tests.
Unit Testswill execute tests.Tests with Coverage, will run tests with coverage.
- In the terminal run ->
npm run storybook - Build Storybook as a static site ->
npm run storybook:build
- In the terminal run ESLint with ->
npm run lint
- In the terminal run Prettier with ->
npm run pretty
If you find anything wrong with this repo post them here please.
Refer to CONTRIBUTING.md in the root of this repo.
I've left myself some work to do. Look in todo.md.