fxa/packages/fxa-auth-db-mysql
dependabot[bot] 4d52527d87
chore(deps-dev): bump nock from 13.0.11 to 13.1.0
Bumps [nock](https://github.com/nock/nock) from 13.0.11 to 13.1.0.
- [Release notes](https://github.com/nock/nock/releases)
- [Changelog](https://github.com/nock/nock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/nock/nock/compare/v13.0.11...v13.1.0)

---
updated-dependencies:
- dependency-name: nock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-04 05:23:54 +00:00
..
.vscode feat: add vscode tasks for running tests and debugger 2019-10-01 17:27:41 -07:00
bin chore(deps): updated dependencies 2020-06-22 17:11:50 -07:00
config chore(deps): updated dependencies 2020-06-22 17:11:50 -07:00
db-server fix(db): Set collation on stored procedure email fields, so mysql will use indexes. 2020-07-22 17:44:56 -07:00
docs feat(aet): Add ecosystemAnonId to auth-db and mysql 2020-07-12 11:58:15 -04:00
lib feat(auth): create script to send subscription renewal reminder emails 2021-05-17 14:29:21 -05:00
scripts fix(build): fix paths to fxa-shared 2020-05-28 19:07:52 -07:00
test fix(db): Set collation on stored procedure email fields, so mysql will use indexes. 2020-07-22 17:44:56 -07:00
.eslintrc task(monorepo): eslint consolidation 2019-11-15 23:24:09 +00:00
.migration-lint-ignore.json feat(scripts): lint-ignore tables that already have foreign keys 2018-11-28 11:19:07 +00:00
.nsprc fix(deps): Add exception for yargs-parser nsp advisory 1500 2020-05-11 11:40:27 -07:00
.prettierignore chore(style): added prettier to fxa-auth-db-mysql 2019-06-25 09:36:41 -07:00
AUTHORS
CHANGELOG-server.md chore(style): added prettier to fxa-auth-db-mysql 2019-06-25 09:36:41 -07:00
CHANGELOG.md Release 1.207.1 2021-06-01 15:44:54 -04:00
CONTRIBUTING.md chore(docs): Replace 'master' with 'main' throughout 2020-06-25 13:44:28 -07:00
LICENSE
README.md chore(deps): update node version to 14 2020-10-27 10:21:05 -07:00
index.js chore(format): mass reformat with prettier 2 and single config 2020-05-24 10:51:57 -07:00
package.json chore(deps-dev): bump nock from 13.0.11 to 13.1.0 2021-06-04 05:23:54 +00:00
pm2.config.js chore(pm2): Add ISO timestamp to pm2 log lines 2020-06-17 17:01:16 -07:00

README.md

Firefox Accounts database service

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

Prerequisites

  • node.js 14
  • npm
  • MySQL (we use version 5.6.42 in production)

Testing

This package uses Mocha to test its code. By default npm test will run all NPM test scripts and then lint the code:

  • npm run test-mysql will test database code under test/backend and test/local.
  • npm run test-server will test server code under db-server/test/local.

Test specific tests with the following commands:

# Test only test/lib/log.js
./scripts/mocha-coverage.js test/lib/log.js

# Grep for "error module" under db-server/test
./scripts/mocha-coverage.js db-server/test/*/** -g "error module"

Refer to Mocha's CLI documentation for more advanced test configuration.

API Server

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

To run the server tests:

npm run test-server

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