Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ additional records with a standardized template.
## Publishing User Facing Documentation

### Automatic generation from openapi specification

- Sign into stoplight.io with an account that has access to the MIT Libraries organization
- copy the source of `openapi.json` file from this repository to the code tab in our [stoplight model](https://next.stoplight.io/mit-libraries/timdex/version%2F1.0/openapi.oas3.yml)
- In [Stoplight's Publish](https://next.stoplight.io/mit-libraries/timdex/version%2F1.0/timdex.hub.yml?view=/&show=publish&domain=mitlibraries-timdex.docs.stoplight.io) section, Uncheck "set live" and then click "Build"
- Once docs are built, check they are sane with the preview feature then click "set live"

## Required Environment Variables (all ENVs)

- `EMAIL_FROM`: email address to send message from, including the registration
- `EMAIL_FROM`: email address to send message from, including the registration
and forgot password messages.
- `EMAIL_URL_HOST` - base url to use when sending emails that link back to the
application. In development, often `localhost:3000`. On heroku, often
Expand All @@ -41,6 +42,7 @@ additional records with a standardized template.
- `ELASTICSEARCH_URL`: defaults to `http://localhost:9200`

## Production required Environment Variables

- `AWS_ACCESS_KEY`
- `AWS_ELASTICSEARCH`: boolean. Set to true to enable AWSv4 Signing
- `AWS_SECRET_ACCESS_KEY`
Expand All @@ -51,7 +53,21 @@ additional records with a standardized template.
- `SMTP_USER`

## Optional Environment Variables (all ENVs)
- `ELASTICSEARCH_LOG` if `true`, verbosely logs ElasticSearch queries

- `ELASTICSEARCH_LOG` if `true`, verbosely logs ElasticSearch queries.

```text
NOTE: do not set this ENV at all if you want ES logging fully disabled.
Setting it to `false` is still setting it and you will be annoyed and
confused.
```

- `ES_LOG_LEVEL` set elasticsearch transport log level. Defaults to `INFO`.

```text
NOTE: `ELASTICSEARCH_LOG` must also be set for logging to function.
```

- `PREFERRED_DOMAIN` - set this to the domain you would like to to use. Any
other requests that come to the app will redirect to the root of this domain.
This is useful to prevent access to herokuapp.com domains.
Expand Down
4 changes: 4 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
Expand Down
7 changes: 5 additions & 2 deletions config/initializers/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def configure_elasticsearch
end

def es_client
Elasticsearch::Client.new log: ENV['ELASTICSEARCH_LOG']
Elasticsearch::Client.new log: ENV.fetch('ELASTICSEARCH_LOG', false)
end

def aws_client
Elasticsearch::Client.new log: ENV['ELASTICSEARCH_LOG'],
Elasticsearch::Client.new log: ENV.fetch('ELASTICSEARCH_LOG', false),
url: ENV['ELASTICSEARCH_URL'] do |config|
config.request :aws_sigv4,
credentials: Aws::Credentials.new(
Expand All @@ -26,3 +26,6 @@ def aws_client
end

Timdex::EsClient = configure_elasticsearch

return unless ENV.fetch('ELASTICSEARCH_LOG', false)
Timdex::EsClient.transport.logger.level = ENV.fetch('ES_LOG_LEVEL', 'INFO')