INACTIVE - http://mzl.la/ghe-archive - To infinity and beyond. The backend API.
Перейти к файлу
Andrew Richardson 0c1f817ba9 Merge pull request #184 from cvan/user-search-error-fix
Fixed a misleading /user/search error
2014-04-09 16:57:19 -07:00
lib Fixed minor issues 2014-04-07 09:30:53 -07:00
scripts Fail on all errors in pre-fill script (was silently failing on validation errors) 2014-04-07 20:12:47 -07:00
static Bust host.html on each load 2013-12-20 14:31:35 -08:00
test Fixed issues from review and added TODO for missing test cases 2014-04-07 20:23:06 +08:00
views Fixed a case where /user/search was always returning a bad_email error when user lookup failed 2014-04-08 16:16:37 -07:00
.gitignore Added directory structure for unit tests 2014-04-07 02:45:50 +08:00
Makefile Added more tests for user 2014-04-07 02:49:24 +08:00
README.md Fixed typo in README.md, minor syntax issue and added TODOs 2014-04-07 20:12:35 +08:00
app.js implement feedback modal endpoint (fixes #123) 2014-03-27 02:05:24 -04:00
db.js Modified redisView in db.js to close redis connections with `client.quit()` instead of `client.end()`, since that is what the documentation recommends. This avoids prematurely closing the connection if a request is still awaiting a reply. See https://github.com/mranney/node_redis#clientend. 2014-03-23 11:37:43 -07:00
game.html Fix game stub URL 2013-12-20 12:23:32 -08:00
package.json Fixed rebase error 2014-04-07 20:22:20 -07:00
server_http.js Removed unused import 2014-04-07 20:18:36 -07:00
server_ws.js fix auth import 2014-02-07 21:42:40 -05:00
settings.js Added persona-faker as a dev dependency so that it can be launched using a script 2014-02-09 09:15:06 -08:00
settings_local.js.dist Updated the prefill data to include game details, and more games 2014-03-23 19:06:07 +08:00
settings_test.js.dist Added directory structure for unit tests 2014-04-07 02:45:50 +08:00
stackato.yml deploy on stackato (fixes #136) 2014-03-10 20:53:56 -07:00

README.md

galaxy-api

Stories in Ready

Here lives the API that is consumed by the front-end interface for cvan/galaxy.

Installation

# Install redis via homebrew
brew install redis
# Install node dependencies
npm install
# Copy local configuration into place
cp settings_local.js.dist settings_local.js
# Start the server
npm start

If you'd like to run the server for development, consider using nodemon instead:

npm install nodemon -g
nodemon app.js

Deployment

We use stackato:

stackato push --no-prompt

To start the instance on stackato:

stackato start

To read the logs on stackato:

stackato logs

To run shell commands on stackato:

stackato run cat ../logs/stdout.log

To access the shell on stackato:

stackato ssh

Sample Usage

Game Submission

curl -X POST 'http://localhost:5000/game/submit?_user=ssa_token' -H 'Content-Type:application/json' -H 'Accept: application/json' -d '{"app_url":"http://nuttyninjas.com/","artwork":{"background":"background.jpg"},"description":"Nutty Ninjas is a real-time shooter that brings the experience of social multiplayer gaming to a whole new level; it is a console-style game that can be played anywhere and anytime, simply with your computer and mobile devices. Multiple players can join a common gameplay screen just by using their mobile devices, and control their ninja character to unleash dangerous weapons at fellow players!","developer":{"name":"Yang Shun","url":"http://yangshun.im/"},"genre":"action","homepage_url":"http://www.nuttyninjas.com","icons":"http://png-4.findicons.com/files/icons/2297/super_mario/256/paper_mario.png","name":"Nutty Ninjas","privacy_policy_url":"http://una-org.github.io/demos.html","screenshots":["http://www.digitaltrends.com/wp-content/uploads/2011/02/nintendo-new-super-mario-bros-ds-art-screenshot.jpg","http://splitkick.com/wp-content/uploads/2013/01/newsuper2img.jpg","http://www.mariowiki.com/images/f/fc/SuperMarioBrosArtwork2.jpg","http://www.digitaltrends.com/wp-content/uploads/2011/02/nintendo-new-super-mario-bros-ds-art-screenshot.jpg","http://splitkick.com/wp-content/uploads/2013/01/newsuper2img.jpg","http://www.mariowiki.com/images/f/fc/SuperMarioBrosArtwork2.jpg","http://www.digitaltrends.com/wp-content/uploads/2011/02/nintendo-new-super-mario-bros-ds-art-screenshot.jpg","http://splitkick.com/wp-content/uploads/2013/01/newsuper2img.jpg","http://www.mariowiki.com/images/f/fc/SuperMarioBrosArtwork2.jpg"],"slug":"nutty-ninjas","videos":["http://www.youtube.com/embed/4kvT0dywaF8","http://www.youtube.com/embed/1Sow2O8D9Ok"]}'

Game Details

curl 'http://localhost:5000/game/nutty-ninjas/detail'

Grant a user admin privileges

./scripts/addusertogroup.js cvan@mozilla.com admin

Grant a user admin+reviewer privileges

./scripts/addusertogroup.js cvan@mozilla.com admin reviewer

Revoke a user's admin privileges

./scripts/removeuserfromgroup.js cvan@mozilla.com admin

Revoke a user's admin+reviewer privileges

./scripts/removeuserfromgroup.js cvan@mozilla.com admin reviewer

Using prefilled data

./scripts/db-prefill.js

To flush the db everytime the script is run, add the following to settings_local.js: exports.FLUSH_DB_ON_PREFILL = true;

Running unit tests

cp settings_test.js.dist settings_test.js
./test/redis_start
make test