Skip to content

Commit

Permalink
[ENH] Added NB_QUERY_PATH env var to configure path variable (#227)
Browse files Browse the repository at this point in the history
* Added `NB_QUERY_PATH` env var to configure path variable

* Renamed `NB_QUERY_PATH` to `NB_QUERY_URL_PATH`

* Added `NB_QUERY_URL_PATH` to the README.md
  • Loading branch information
rmanaem authored Aug 2, 2024
1 parent 36f8231 commit d73211c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ but before proceeding with either you need to set the environment variables.

### Mandatory configuration

| Environment variable | Type | Required | Default value if not set | Example |
| -------------------- | ------- | -------------------------------------- | ------------------------ | ------------------------------------------------------- |
| NB_API_QUERY_URL | string | Yes | - | https://federate.neurobagel.org/ |
| NB_IS_FEDERATION_API | boolean | No | true | true |
| 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 |
| Environment variable | Type | Required | Default value if not set | Example |
| ---------------------- | ------- | ---------------------------------------- | ------------------------ | --------------------------------------------------------- |
| `NB_API_QUERY_URL` | string | Yes | - | `https://federate.neurobagel.org/` |
| `NB_IS_FEDERATION_API` | boolean | No | `true` | `true` |
| `NB_QUERY_URL_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_API_QUERY_URL`

Expand All @@ -62,6 +63,10 @@ You'll need to set the `NB_API_QUERY_URL` environment variable required to run t

If the API you'd like to send queries to is not a [federation api](https://neurobagel.org/federate/), you need to set the `NB_IS_FEDERATION_API` to `false` as it is `true` by default.

#### `NB_QUERY_URL_PATH`

If you are using a custom configuration where the query tool is accessible via a path other than the root (`/`), you need to set the `NB_QUERY_URL_PATH` to your custom path. This ensures that the query tool is correctly rendered and accessible at the specified URL

#### `NB_ENABLE_AUTH`

If the API you'd like to send queries to requires authentication, you need to set `NB_ENABLE_AUTH` to `true` as it is `false` by default. This will enable authentication flow of the app.
Expand Down
4 changes: 2 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { StyledEngineProvider } from '@mui/material/styles';
import { GoogleOAuthProvider } from '@react-oauth/google';
import App from './App';
import { enableAuth, clientID } from './utils/constants';
import { queryURLPath, enableAuth, clientID } from './utils/constants';
import './index.css';

const router = createBrowserRouter([
{
path: '/',
path: queryURLPath,
element: <App />,
},
]);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const isFederationAPI: boolean =
? true
: import.meta.env.NB_IS_FEDERATION_API.toLowerCase() === 'true';

export const queryURLPath: string = import.meta.env.NB_QUERY_URL_PATH ?? '/';

export const enableAuth: boolean =
import.meta.env.NB_ENABLE_AUTH === undefined
? false
Expand Down

0 comments on commit d73211c

Please sign in to comment.