At meltmedia, we organize recurring Fitbit competitions that run for up to a month at a time. People really get into it and there are some great prizes at the end. At some point, we decided to hook into the Fitbit API and make our own custom "Fitbit Leaderboard" website for our team. Now we've opened it up to the world! And we used responsive design, so it works great on all screens!
Feel free to personalize it for your team, and let people know where you found it :)
Read about our Fitbit shenanigans on our blog.
Step on wif yo bad self!
Clone the repository into your local git directory, install dependencies and run the project.
git clone [email protected]:meltmedia/fitbit-leaderboard.git
cd fitbit-leaderboard
npm install
npm install -g grunt-cli
grunt dev
Click the link and follow the instructions to install Mongo.
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
You will need the following environment variables:
FITBIT_APP_SECRET
: a secret passphrase for encryptionFITBIT_UPDATE_INTERVAL
: interval in milliseconds to update leaderboard (optional, defaults to 300000)FITBIT_APP_HOST
: the host for your app (not used in local dev)FITBIT_LEADERBOARD_START
: start date for challenge (format: YYYY-MM-DD)FITBIT_LEADERBOARD_END
: end date for challenge (format: YYYY-MM-DD)FITBIT_REGISTRATION_NAME
: a username to share with users to restrict ability to join leaderboard (optional, defaults to empty string)FITBIT_REGISTRATION_PASSPHRASE
: a passphrase to share with users to restrict ability to join leaderboard (optional, ability to join is unrestricted when env var is not present)
The update interval, dates and host can also be configured in a config.json
file placed in the root of the project. Environment variables will override the config.json
settings. See example below:
{
"dates": {
"startDate": "2015-01-30",
"endDate": "2015-02-28"
},
"host": "fitbit.mysite.com",
"updateInterval": 150000
}
FITBIT_API_KEY
: Fitbit API keyFITBIT_API_SECRET
: Fitbit API secret
FITBIT_MONGO_USER
: Mongo username (optional in local dev, defaults to empty string)FITBIT_MONGO_PASSPHRASE
: Mongo passphrase (optional in local dev, defaults to empty string)FITBIT_MONGO_HOST
: Mongo host (optional in local dev, defaults tolocalhost
)FITBIT_MONGO_DB
: Mongo database name (optional in local dev, defaults tofitbit-leaderboard
)
The Loggly environment variables are not required for your app to run. If using Loggly, either FITBIT_LOGGLY_INPUTTOKEN
or FITBIT_LOGGLY_INPUTNAME
is required. If using FITBIT_LOGGLY_INPUTNAME
, then FITBIT_LOGGLY_USERNAME
and FITBIT_LOGGLY_PASSWORD
are also required.
FITBIT_LOGGLY_SUBDOMAIN
: The subdomain of your Loggly accountFITBIT_LOGGLY_INPUTTOKEN
: The input token of the input this instance should log toFITBIT_LOGGLY_INPUTNAME
: The name of the input this instance should log toFITBIT_LOGGLY_USERNAME
: The username for your Loggly account.FITBIT_LOGGLY_PASSWORD
: The password for your Loggly account.
- Run the project locally:
grunt dev
(will open app at http://127.0.0.1:5455/) - Build the dist files:
grunt build
- Run in not production mode:
grunt not-prod
- Run in production mode:
grunt prod
grunt
is an alias ofgrunt dev
If using ACLs to restrict registration instead of the shared basic auth user, make sure that /leaderboard
and /api/public
are public and /auth
is private.