GithubHelp home page GithubHelp logo

robberthalff / fxa-auth-db-mysql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/fxa-auth-db-mysql

0.0 2.0 0.0 538 KB

MySql backend for the fxa-auth-db-server

License: Mozilla Public License 2.0

JavaScript 97.83% SQLPL 0.88% Shell 1.29%

fxa-auth-db-mysql's Introduction

Firefox Accounts database service

Build Status

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

  • The API server. Also published independently via npm as fxa-auth-db-server, to enable use with alternative backend storage.
  • A memory-store backend. Useful as a stub for testing against.
  • A MySQL backend. Used in production.

To run the tests for all components:

npm test

Prerequisites

  • Node.js 0.10 or later
  • npm
  • MySQL (we use version 5.6.21 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.

Docker-based development

To run the MySQL backend inside a container, use the following commands:

docker build --rm -t mozilla/fxa_auth_db_mysql .
docker run --rm -v $PWD:/opt/fxa mozilla/fxa_auth_db_mysql npm install
docker run -it --rm -v $PWD:/opt/fxa --net=host mozilla/fxa_auth_db_mysql

This method shares the codebase into a container and runs the MySQL backend inside it. You can npm install and edit code in your normal desktop environment and the changes will be picked up automatically.

License

MPL 2.0

fxa-auth-db-mysql's People

Contributors

chilts avatar rfk avatar jrgm avatar dannycoates avatar philbooth avatar rhalff avatar pdehaan avatar eoger avatar jamonation avatar tda avatar vladikoff avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.