<commit_before># ripple-rest

A RESTful API for submitting payments and monitoring accounts on the Ripple Network.

See the [__API Reference__](docs/api-reference.md) for details on the available endpoints and supported data formats.


## Installing and Running

`ripple-rest` requires PostgreSQL for production systems but supports in-memory sqlite3 for testing.

### Running using in-memory SQLite3

1. Run `git clone https://github.com/ripple/ripple-rest.git` in a terminal and switch into the `ripple-rest` directory
2. `cp config-example.json config.json` and remove "DATABASE_URL" line.
3. Run `npm install` to install dependencies
4. Run `node server.js` to start the server
5. Visit [`http://localhost:5990`](http://localhost:5990) to view available endpoints and to get started

Note that restarting the server will delete the database so this CANNOT BE USED IN PRODUCTION.

### Running in a Virtual Machine

#### On Linux

1. Run `git clone https://github.com/ripple/ripple-rest.git` in a terminal and switch into the `ripple-rest` directory
2. `cp config-example.json config.json` and configure DATABASE_URL appropriately
3. Run `npm install` to install the dependencies and setup the database
4. Run `node server.js` to start the server
5. Visit `http://localhost:5990/api/v1/status` in your browser to confirm that the server is up and running

#### On Mac OSX

1. Install [Fig](http://orchardup.github.io/fig/install.html) and dependencies listed on that page
2. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
3. Run `docker-osx shell` (not needed on Linux)
4. Run `fig up` or, on OSX, `PYTHONIOENCODING=utf-8 fig up` to start virtual machine
5. Visit [`http://localdocker:5990`](http://localdocker:5990) to view available endpoints and to get started

### Running with an existing PostgreSQL Installation

1. Run `git clone <EMAIL>@github.com:ripple/ripple-rest.git` to clone repository
2. Set the `DATABASE_URL` environment variable to point to your (configured and running) PostgreSQL instance. You can temporarily set the environment variable by running `export DATABASE_URL=postgres://{user}:{password}@{host}:{port}/{database}`. That variable can be more permanently set by adding the export line your shell configuration (default is `$HOME/.bashrc`) or to `/etc/environment`.
3. Run `npm install` to install dependencies and run database migrations
4. If the PostgreSQL connection will run over HTTPS, run `npm install --save pg`. The default node.js PostgreSQL module does not require native drivers but this version does, which enables support for HTTPS.
5. Run `node server.js` to start the server
6. Visit [`http://localhost:5990`](http://localhost:5990) to view available endpoints and to get started

Note that if `npm install` fails because the user running it does not have sufficient permissions to access and modify the database, the command `./node_modules/.bin/grunt` must be run with sufficient permissions to execute database migrations.


## Configuring `ripple-rest`

The `ripple-rest` server loads configuration options from the following sources, according to the following hierarchy (where options from 1. override those below it):
<commit_msg>[DOC] Add global install of pg module<commit_after># ripple-rest

A RESTful API for submitting payments and monitoring accounts on the Ripple Network.

See the [__API Reference__](docs/api-reference.md) for details on the available endpoints and supported data formats.


## Installing and Running

`ripple-rest` requires PostgreSQL for production systems but supports in-memory sqlite3 for testing.

### Running using in-memory SQLite3

1. Run `git clone https://github.com/ripple/ripple-rest.git` in a terminal and switch into the `ripple-rest` directory
2. `cp config-example.json config.json` and remove "DATABASE_URL" line.
3. Run `npm install` to install dependencies
4. Run `node server.js` to start the server
5. Visit [`http://localhost:5990`](http://localhost:5990) to view available endpoints and to get started

Note that restarting the server will delete the database so this CANNOT BE USED IN PRODUCTION.

### Running in a Virtual Machine

#### On Linux

1. Run `git clone https://github.com/ripple/ripple-rest.git` in a terminal and switch into the `ripple-rest` directory
2. `cp config-example.json config.json` and configure DATABASE_URL appropriately
3. Run `npm install` to install the dependencies and setup the database
4. Run `node server.js` to start the server
5. Visit `http://localhost:5990/api/v1/status` in your browser to confirm that the server is up and running

#### On Mac OSX

1. Install [Fig](http://orchardup.github.io/fig/install.html) and dependencies listed on that page
2. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
3. Run `docker-osx shell` (not needed on Linux)
4. Run `fig up` or, on OSX, `PYTHONIOENCODING=utf-8 fig up` to start virtual machine
5. Visit [`http://localdocker:5990`](http://localdocker:5990) to view available endpoints and to get started

### Running with an existing PostgreSQL Installation

1. Run `git clone <EMAIL>.com:ripple/ripple-rest.git` to clone repository
2. Set the `DATABASE_URL` environment variable to point to your (configured and running) PostgreSQL instance. You can temporarily set the environment variable by running `export DATABASE_URL=postgres://{user}:{password}@{host}:{port}/{database}`. That variable can be more permanently set by adding the export line your shell configuration (default is `$HOME/.bashrc`) or to `/etc/environment`.
3. Install the pg module globally for postgres database access: `sudo npm install -g pg`.
4. Run `npm install` to install dependencies and run database migrations
5. If the PostgreSQL connection will run over HTTPS, run `npm install --save pg`. The default node.js PostgreSQL module does not require native drivers but this version does, which enables support for HTTPS.
6. Run `node server.js` to start the server
7. Visit [`http://localhost:5990`](http://localhost:5990) to view available endpoints and to get started

Note that if `npm install` fails because the user running it does not have sufficient permissions to access and modify the database, the command `./node_modules/.bin/grunt` must be run with sufficient permissions to execute database migrations.


## Configuring `ripple-rest`

The `ripple-rest` server loads configuration options from the following sources, according to the following hierarchy (where options from 1. override those below it):

{'fraction_non_alphanumeric': 0.08803195575357198, 'fraction_numerical': 0.01674604393916116, 'mean_word_length': 4.766164747564216, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1906069', 'n_tokens_mistral': 1851, 'n_tokens_neox': 1744, 'n_words': 839}