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.
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.
Installation
Ensure prerequisities are installed:
PostgreSQL
To install using Homebrew on Mac OS X:
Install Node dependencies:
These production dependencies will be installed:
And these developer dependencies will be installed:
Create a PostgreSQL database (using
settings.POSTGRES_URLfromsettings_dev.js):Initialise settings, if you haven’t already:
Developing locally
Initialise settings, if you haven’t already:
To run the local web server:
To run with a different settings file:
To run linting tools:
Deploying to production
Initialise settings, if you haven’t already:
To run the web server in production:
To run with a different settings file:
Alternatively, without
npm:Running tests
Initialise settings, if you haven’t already:
To run tests:
To run a single test:
To run tests without destroying the database first:
To run tests with coverage and linting:
Working with the database
All data is currently stored in a relational PostgreSQL database (previously redis was used).
gulptasksThese are the available
gulptasks for PostgreSQL database and migration operations:gulp createdb- create a PostgreSQL database usingsettings.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.psqlcommandsTo access the PostgreSQL prompt:
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.Examples of using the API
Below are sample
curlcommands for interacting with the REST API endpoints.NOTE: This should eventually also live elsewhere in the real API docs, but for now: it’s fine; it’s fine.
Games
[
GET /games] gameControllersTo retrieve a list of all game resources.
[
POST /games] gameControllersTo create a game resource.
[
GET /games/{idOrSlug}] gameControllersTo retrieve a game resource.
[
DELETE /games/{idOrSlug}] gameControllersTo (soft-)delete a game resource.
[
PUT /games/{idOrSlug}] gameControllersTo update a game resource.