Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Document NB_QUERY_HEADER_SCRIPT #468

Merged
merged 5 commits into from
Feb 2, 2025
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
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ but before proceeding with either you need to set the environment variables.
| `NB_API_QUERY_URL` | string | Yes | - | `https://federate.neurobagel.org/` |
| `NB_QUERY_APP_BASE_PATH` | string | No | `/` | `/query/` |
| `NB_ENABLE_AUTH` | boolean | No | `false` | `false` |
| `NB_QUERY_CLIENT_ID` | string | Yes (if `NB_ENABLE_AUTH` is set to true) | - | `46923719231972-dhsahgasl3123.apps.googleusercontent.com` |
| `NB_QUERY_CLIENT_ID` | string | Yes (if `NB_ENABLE_AUTH` is set to true) | - | `""` |
| `NB_QUERY_HEADER_SCRIPT` | string | No | `""` | `'<script defer data-domain="mydomain" src="plausible">'` |

#### `NB_API_QUERY_URL`

Expand All @@ -64,6 +65,17 @@ If the API you'd like to send queries to requires authentication, you need to se
If the `NB_ENABLE_AUTH` is set to `true` (it is `false` by default), you need to provide a valid client ID for the authentication.
_At the moment, query tool uses Google for authentication, so you need to obtain a client ID from Google developer console. See [documentation](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid) for more information._

#### `NB_QUERY_HEADER_SCRIPT`

If you want to add a custom script to the header of the query tool, you can set the `NB_QUERY_HEADER_SCRIPT` environment variable to the script you want to add.
This script will be added to the header of the query tool. For example, in our production deployment we use the GDPR aware analytics tool [Plausible](https://plausible.io/),
so we set the `NB_QUERY_HEADER_SCRIPT` to the script provided by Plausible.
When you use this variable, make sure you use single quotes to include the script like so:

```bash
NB_QUERY_HEADER_SCRIPT='<script defer data-domain="mydomain" src="plausible">'
```

#### Set the environment variables

To set environment variables, create a `.env` file in the root directory and add the environment variables there. If you're running a neurobagel node-API locally on your machine (following the instructions [here](https://github.com/neurobagel/api#local-installation)), your `.env` file would look something like this:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
for file in $(find /usr/share/nginx/html -type f \( -name "*.js" -o -name "*.html" \)); do
sed -i "s|REPLACE_ME_NB_API_QUERY_URL_REPLACE_ME|${NB_API_QUERY_URL}|g" "$file"
sed -i "s|REPLACE_ME_NB_ENABLE_AUTH_REPLACE_ME|${NB_ENABLE_AUTH:-false}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_CLIENT_ID_REPLACE_ME|${NB_QUERY_CLIENT_ID:-testclient1234}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_CLIENT_ID_REPLACE_ME|${NB_QUERY_CLIENT_ID}|g" "$file"
sed -i "s|REPLACE_ME_NB_ENABLE_CHATBOT_REPLACE_ME|${NB_ENABLE_CHATBOT:-false}|g" "$file"
sed -i "s|REPLACE_ME_NB_QUERY_APP_BASE_PATH_REPLACE_ME|${NB_QUERY_APP_BASE_PATH:-/}|g" "$file"
sed -i "s|<!-- REPLACE_ME_NB_QUERY_HEADER_SCRIPT_REPLACE_ME -->|${NB_QUERY_HEADER_SCRIPT}|g" "$file"
Expand Down