Skip to content

Commit

Permalink
add dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
lebalz committed Jul 5, 2024
1 parent 1495b50 commit 351761d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati

## ENV

| Variable | For | Default | Example | Description |
|:--------------|:------------|:------------------------|:--------------------|:-----------------------------------------------------------------------------------------------------------------------------------|
| APP_URL | Production | `http://localhost:3000` | | Domain of the hosted app |
| BACKEND_URL | Production | `http://localhost:3002` | | Url of the API Endpoint |
| CLIENT_ID | Production | | | Azure ID: Client ID |
| TENANT_ID | Production | | | Azure AD: Tenant Id |
| API_URI | Production | | | Azure AD: API Url |
| TEST_USERNAME | Development | | `admin.bar@bazz.ch` | To log in offline. Must be the same as `ADMIN_EMAIL` or `USER_EMAIL` in [👉 Dev-Backend](https://github.com/lebalz/events-api#env) |
| Variable | For | Default | Example | Description |
|:--------------|:------------|:------------------------|:--------------------|:------------------------------------------------------------------------------------|
| APP_URL | Production | `http://localhost:3000` | | Domain of the hosted app |
| BACKEND_URL | Production | `http://localhost:3002` | | Url of the API Endpoint |
| CLIENT_ID | Production | | | Azure ID: Client ID |
| TENANT_ID | Production | | | Azure AD: Tenant Id |
| API_URI | Production | | | Azure AD: API Url |
| TEST_USERNAME | Development | | `admin.bar@bazz.ch` | To log in offline. Must be the same as `ADMIN_EMAIL` or `USER_EMAIL` in the Backend |
3 changes: 2 additions & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('dotenv').config();
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
Expand Down Expand Up @@ -56,7 +57,7 @@ const config: Config = {
customFields: {
/** Use Testuser in local dev: set TEST_USERNAME to the test users email adress*/
TEST_USERNAME: process.env.TEST_USERNAME,
NO_AUTH: process.env.NODE_ENV !== 'production' && process.env.TEST_USERNAME?.length > 0,
NO_AUTH: process.env.NODE_ENV !== 'production' && !!process.env.TEST_USERNAME,
/** The Domain Name where the api is running */
APP_URL: process.env.APP_URL || 'http://localhost:3000',
/** The Domain Name of this app */
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"clsx": "^2.0.0",
"docusaurus-live-brython": "^3.0.0-beta.22",
"docusaurus-plugin-sass": "^0.2.5",
"dotenv": "^16.4.5",
"known-css-properties": "^0.34.0",
"lodash": "^4.17.21",
"mobx": "^6.13.0",
Expand Down
2 changes: 1 addition & 1 deletion src/pages/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const UserPage = observer(() => {
<h2>User</h2>
<pre>
<code>
{JSON.stringify(current.props, null, 2)}
{JSON.stringify(current?.props, null, 2)}
</code>
</pre>
</main>
Expand Down
1 change: 1 addition & 0 deletions src/theme/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DocumentRootStore } from '../stores/DocumentRootStore';
const { NO_AUTH, TEST_USERNAME } = siteConfig.customFields as { TEST_USERNAME?: string; NO_AUTH?: boolean };
export const msalInstance = new PublicClientApplication(msalConfig);

console.log(NO_AUTH, TEST_USERNAME);
if (NO_AUTH) {
const n = TEST_USERNAME.length >= 40 ? 0 : 40 - TEST_USERNAME.length;
console.log(
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,11 @@ dot-prop@^6.0.1:
dependencies:
is-obj "^2.0.0"

dotenv@^16.4.5:
version "16.4.5"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

duplexer@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
Expand Down

0 comments on commit 351761d

Please sign in to comment.