⚔️ A GoT-themed weekly predictions game 🐉 (built from aqua framework)
Branch: master
Clone or download
Pull request Compare This branch is 147 commits ahead, 32 commits behind jedireza:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client
data
gulp
public
server
test
.babelrc
.editorconfig
.env-sample
.eslintignore
.eslintrc.json
.gitignore
.travis.yml
LICENSE
Procfile
README.md
config.js
first-time-setup.js
gulpfile.js
index.js
maintenance.html
manifest.js
package.json
server.js

README.md

Requirements

You need Node.js installed and you'll need MongoDB installed and running.

on Mac, run:

$ brew install node
$ brew install mongodb

Installation

Ensure you have mongodb running (in a separate tab) with:

$ mongod
$ git clone git@github.com:johnstoecker/ironwagers.git
$ cd ironwagers
$ npm install
$ cp .env-sample .env
$ npm run first-time-setup
$ npm start

..and open up http://127.0.0.1:8000/

Troubleshooting Installation

We use bcrypt for hashing secrets. If you have issues during installation related to bcrypt then refer to this wiki page.

If the server crashes with 'unknow option: --inspect', your node version is out of date. Upgrade to at least v7.10.0

Kit's Area

Open up Iterm2:

  1. In one tab:
sudo ~/Documents/personal/mongodb/bin/mongod
  1. In another tab (cmd+t):
cd ~/projects/ironwagers
git pull
npm start
  1. Open up Chrome and point to localhost:8000
  2. Open up Sublime Text 2. CSS can be edited in client/stylesheets/components.less ...
  3. Once are happy with your changes, you can ctrl-c to shut down each tab. In the ironwagers folder, do a:
git status
git add client/stylesheets/components.less
git commit -m "CSS change -- giving tywin brown trousers"
git push

You can git add whatever other files you like. Having trouble with git push? do:

git pull
hit the Esc button then type :wq
git push

Technology

IronWagers is built off of Aqua: Server side, Aqua is built with the hapi framework. We're using MongoDB as a data store.

The front-end is built with React. We use Redux as our state container. Client side routing is done with React Router. We're using Gulp for the build system.

Configuration

Simply edit config.js. The configuration uses confidence which makes it easy to manage configuration settings across environments. Don't store secrets in this file or commit them to your repository.

Instead, access secrets via environment variables. We use dotenv to help make setting local environment variables easy (not to be used in production).

Simply copy .env-sample to .env and edit as needed. Don't commit .env to your repository.

First time setup

WARNING: This will clear all data in the following MongoDB collections if they exist: accounts, adminGroups, admins, authAttempts, sessions, statuses, and users.

$ npm run first-time-setup

# > aqua@0.0.0 first-time-setup /home/jedireza/projects/aqua
# > node first-time-setup.js

# MongoDB URL: (mongodb://localhost:27017/aqua)
# Root user email: jedireza@gmail.com
# Root user password:
# Setup complete.

Running the app

$ npm start

# > aqua@0.0.0 start /Users/jedireza/projects/aqua
# > gulp react && gulp

# [23:41:44] Using gulpfile ~/projects/aqua/gulpfile.js
# ...

Now you should be able to point your browser to http://127.0.0.1:8000/ and see the welcome page.

nodemon watches for changes in server code and restarts the app automatically. gulp and webpack watch the front-end files and re-build those automatically too.

We also pass the --inspect flag to Node so you have a debugger available. Watch the output of $ npm start and look for the debugging URL and open it in Chrome. It looks something like this:

chrome-devtools://devtools/remote/serve_file/@62cd277117e6f8ec53e31b1be58290a6f7ab42ef/inspector.html?experiments=true&v8only=true&ws=localhost:9229/node

Running in production

$ node server.js

Unlike $ npm start this doesn't watch for file changes. Also be sure to set these environment variables in your production environment:

  • NODE_ENV=production - This is important for many different optimizations, both server-side and with the front-end build files.
  • NPM_CONFIG_PRODUCTION=false - This tells $ npm install to not skip installing devDependencies, which we need to build the front-end files.

Have a question?

If you see something, say something!

Want to contribute?

Contributions are welcome.

Running tests

Lab is part of the hapi ecosystem and what we use to write all of our tests.

$ npm test

# > aqua@0.0.0 test /Users/jedireza/projects/aqua
# > lab -t 100 -S -T ./test/lab/transform -L --lint-options '{"extensions":[".js",".jsx"]}' ./test/lab/client-before.js ./test/client/ ./test/lab/client-after.js ./test/server/ ./test/lab/server-after.js ./test/misc/

#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ..................................................
#  ...............

# 865 tests complete
# Test duration: 6382 ms
# No global variable leaks detected
# Coverage: 100.00%
# Linting results: No issues

License

MIT

Don't forget

The Iron Bank will have its due.