INACTIVE - http://mzl.la/ghe-archive - To infinity and beyond. The backend API.
Перейти к файлу
Christopher Van db1e039026 add a `.jshintrc` 2015-01-05 16:02:01 -08:00
api add `lab` for unit testing; add tests for `lib.utils.isStringAnInt` (issue #309) 2014-12-19 17:28:56 -08:00
images add galaxy-api logo to README 2014-09-02 11:41:28 -07:00
lib/utils add tests for `lib.utils.returnError` (issue #309) 2014-12-19 17:28:56 -08:00
migrations implement `DELETE /games/{idOrSlug}` in hapi; exclude soft-deleted games (fixes #262; fixes #293) 2014-12-19 17:28:55 -08:00
test/lib/utils fix grammar in `utils.errors` unit test 2014-12-22 14:07:58 -08:00
.gitignore load Redis only once, add separate dev/prod/test settings files, use different Redis for database for tests 2014-08-25 16:20:27 -07:00
.jshintrc add a `.jshintrc` 2015-01-05 16:02:01 -08:00
.travis.yml add gulp tasks for DB operations (issue #311); swap DB when running tests (issue #312) 2015-01-02 20:34:19 -08:00
CONTRIBUTING.md add CONTRIBUTING.md 2014-08-28 16:36:19 -07:00
LICENCE add LICENCE 2014-08-28 16:36:19 -07:00
README.md change `alt`+`title` text for logo in README 2015-01-05 15:48:52 -08:00
apiary.apib api docs: fix /game -> /games (fixes #238) 2014-09-08 08:37:52 +02:00
gulpfile.js add gulp tasks for DB operations (issue #311); swap DB when running tests (issue #312) 2015-01-02 20:34:19 -08:00
index.js add gulp tasks for DB operations (issue #311); swap DB when running tests (issue #312) 2015-01-02 20:34:19 -08:00
package.json suppress gulp standard output when running tests 2015-01-05 15:21:19 -08:00
settings.js add gulp tasks for DB operations (issue #311); swap DB when running tests (issue #312) 2015-01-02 20:34:19 -08:00
settings_dev.js.dist load Redis only once, add separate dev/prod/test settings files, use different Redis for database for tests 2014-08-25 16:20:27 -07:00
settings_prod.js.dist load Redis only once, add separate dev/prod/test settings files, use different Redis for database for tests 2014-08-25 16:20:27 -07:00
settings_test.js.dist add gulp tasks for DB operations (issue #311); swap DB when running tests (issue #312) 2015-01-02 20:34:19 -08:00

README.md

galaxy-api

Build Status

Here lies the API for Galaxy.

There is a REST HTTP API and WebSocket API. The REST API can be consumed by game developers. The WebSocket API is intended to be consumed by galaxy.js, a simple drop-in JavaScript API for multiplayer, web-based games.

Note: This project is not ready for prime time. Not an official Mozilla project. Pre-alpha everything. Anything and everything at your own risk.

Installation

To install dependencies:

npm install

Other dependencies:

  • PostgreSQL (brew install postgresql && brew info postgresql using Homebrew on Mac OS X)

Create a PostgreSQL database:

createdb galaxy-api

Development

Initialise settings, if you haven't already:

cp ./settings_dev.js.dist ./settings_dev.js

Set these environment variables:

NODE_ENV=development
GALAXY_API_SETTINGS=./settings_dev.js

To run the local web server:

nodemon index.js

Alternatively:

npm run dev

To run linting tools:

gulp lint

Production

Initialise settings if you haven't already:

cp ./settings_prod.js.dist ./settings_prod.js

Set these environment variables:

NODE_ENV=production
GALAXY_API_SETTINGS=./settings_prod.js

To run the web server in production:

node index.js

Alternatively:

npm run prod

Testing

Initialise settings:

cp ./settings_test.js.dist ./settings_test.js

To run tests:

npm test

To run tests without destroying the database first:

npm run test-keepdb

To run tests with coverage and linting:

npm run test-verbose

Database

gulp tasks

These are the available gulp tasks for PostgreSQL database and migration operations:

  • gulp createdb - create a PostgreSQL database using settings.POSTGRES_URL.
  • gulp dropdb - delete the database.
  • gulp migratedb - run migrations.
  • gulp migratedb-create --name <name> - create a new migration file called <name>.
  • gulp migratedb-up - run all up migrations from the current state.
  • gulp migratedb-up --num <num> - run <num> up migrations from the current state.
  • gulp migratedb-down - run a single down migration.
  • gulp migratedb-down --num <num> - run <num> down migrations from the current state.

psql commands

To access the PostgreSQL prompt:

psql -d galaxy-api

These are a few helpful PostgreSQL commands:

  • \h - view list of available commands.
  • \dt+ - list all tables in the database.
  • \d+ <table_name> - show a table's schema.
  • drop table <table_name> - delete a table.
  • \x on - view a table in "extended display" mode.