MySql backend for the fxa-auth-db-server
Clone or download
Latest commit a1a44fe Oct 16, 2018
Permalink
Failed to load latest commit information.
.circleci feat(ci): update to circle 2 (#375) r=@vbudhram Jul 18, 2018
bin fix(db): remove database configuration option, hardcode 'fxa'  (#314) r= Mar 9, 2018
config refactor(recovery): Use base32 for recovery code generation (#372), r=@… Jul 10, 2018
db-server fix(mem): ensure emailBounces are stored most-recent first Oct 16, 2018
docs feat(account): add `profileChangedAt` property to account table Sep 24, 2018
grunttasks refactor(dbserver): clean up the db server package (#289) r=@rfk Nov 28, 2017
lib Merge pull request #406 from mozilla/i405-add-index-for-deleting-sign… Oct 16, 2018
scripts chore(scripts): disable the explain script in production Sep 17, 2018
test fix(tests): move local utils tests so they get run by npm t (#377) r=@… Jul 20, 2018
.dockerignore feat(docker): Additional Dockerfile for self-hosting Jan 21, 2016
.eslintrc feat(scripts): add script to automate MySQL EXPLAIN checks Sep 17, 2018
.explain-ignore feat(scripts): add an ignore file for the explain script Sep 17, 2018
.gitignore refactor(dbserver): clean up the db server package (#289) r=@rfk Nov 28, 2017
.nsprc fix(deps): update to restify 7.1 and mysql 2.15 (#351), r=@rfk May 10, 2018
.travis.yml chore(deps): Update deps to fix security warnings, remove nsp Oct 8, 2018
AUTHORS fix(docs): update authors and node.js version in README May 1, 2017
CHANGELOG-server.md chore(project): merge db-server project admin/config stuff to top level Aug 4, 2015
CHANGELOG.md Release v1.123.0 Oct 16, 2018
CONTRIBUTING.md refactor(dbserver): clean up the db server package (#289) r=@rfk Nov 28, 2017
Dockerfile-build fix(docker): base image node:8-alpine and upgrade to npm6 Jun 13, 2018
Dockerfile-test feat(docker): add docker via Circle CI (#212) r=jbuck,seanmonstar Mar 5, 2017
Gruntfile.js chore(project): merge db-server project admin/config stuff to top level Aug 4, 2015
LICENSE Add the full text of the MPL 2.0 Sep 22, 2014
README.md chore(docs): update mysql docs (#391) r=@rfk Aug 23, 2018
index.js refactor(dbserver): clean up the db server package (#289) r=@rfk Nov 28, 2017
npm-shrinkwrap.json Release v1.123.0 Oct 16, 2018
package.json Release v1.123.0 Oct 16, 2018

README.md

Firefox Accounts database service

Build Status CircleCI

Node.js-based database service for Firefox Accounts. Includes:

To run the tests for all components:

npm test

Prerequisites

  • node.js 6
  • npm
  • MySQL (we use version 5.6.34 in production)

API Server

See the API documentation. Backend implementers should also read the database documentation.

For example usage, see the readme.

To run the server tests:

npm run test-server

Memory-store backend

Implements the backend API as a memory store.

This is the backend store that is loaded by the default export from the npm package, so the following call to require will return a server that uses the memory-store backend:

var fxadb = require('fxa-auth-db-mysql')

To run the memory-store tests:

npm run test-mem

MySQL backend

Implements the backend API as a MySQL database.

To run the MySQL tests:

npm run test-mysql

Configuration

Both the server and the database patcher read values from a config file config/$NODE_ENV.json, where NODE_ENV is an environment variable set in the shell.

For local development, set NODE_ENV to dev then create a new JSON file called config/dev.json. In there, you can set any values that you'd like to override the master config file, config/config.js.

For instance:

{
  "master": {
    "user": "root",
    "password": "foo"
  },
  "slave": {
    "user": "root",
    "password": "bar"
  }
}

Starting the server

You can start the server like so:

npm start

This will set up the database for you then start the server on whichever port is configured in config/$NODE_ENV.json (port 8000 by default).

If the server fails to start, check that MySQL is running and that your active config has the correct settings to connect to the database.

Setting-up the database separately

If you want to run the database patcher on its own, use the following command:

node bin/db_patcher.js

This command creates the database if it doesn't exist, then runs migrations from lib/db/schema in the appropriate order. Both forward and reverse migrations are contained in this directory, but note that the reverse migrations are commented out as a precaution against accidental execution.

If the command fails, check that MySQL is running and that your active config has the correct settings to connect to the database.

Clean-up

If you want to clean the database, just drop it in MySQL:

mysql -u root -p -e 'DROP DATABASE fxa'

It will be recreated automatically next time you run npm start.

License

MPL 2.0