Skip to content

Commit

Permalink
[MS] Adds .env for production and rc
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 committed Aug 21, 2024
1 parent 8488547 commit 4d45f1a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .cspell/cspell.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ignorePaths:
- "**/gradle/verification-metadata.xml"
- "**/*.icns"
- "**/.git"
- "**/client/.env.development"
- "**/client/.env.*"
import:
- "@cspell/dict-fr-fr/cspell-ext.json"
- "@cspell/dict-fr-reforme/cspell-ext.json"
Expand Down
3 changes: 3 additions & 0 deletions client/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BMS_API_URL=https://bms.parsec.cloud
VITE_STRIPE_API_KEY=pk_live_5hF9sn4DLUTYWx9uWPDJv51s00Q8ktUVfI
VITE_SIGN_URL=https://sign.parsec.cloud
3 changes: 3 additions & 0 deletions client/.env.release-candidate
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VITE_BMS_API_URL=https://bms-dev.parsec.cloud
VITE_STRIPE_API_KEY=pk_test_P4dfuyoLBQtDHKjTiNDH3JH700TT3mCLbE
VITE_SIGN_URL=https://sign-dev.parsec.cloud
13 changes: 8 additions & 5 deletions client/src/services/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import { EnvironmentType } from 'megashark-lib';

const STRIPE_ENV_VARIABLE = 'VITE_STRIPE_API_KEY';
// cspell:disable-next-line
const DEFAULT_STRIPE_API_KEY = 'pk_live_5hF9sn4DLUTYWx9uWPDJv51s00Q8ktUVfI';
const DEFAULT_STRIPE_API_KEY = 'pk_test_P4dfuyoLBQtDHKjTiNDH3JH700TT3mCLbE';

function getStripeApiKey(): { key: string; mode: EnvironmentType } {
if (import.meta.env[STRIPE_ENV_VARIABLE]) {
return { key: import.meta.env[STRIPE_ENV_VARIABLE], mode: EnvironmentType.Development };
return {
key: import.meta.env[STRIPE_ENV_VARIABLE],
mode: (import.meta.env[STRIPE_ENV_VARIABLE] as string).startsWith('pk_live_') ? EnvironmentType.Production : EnvironmentType.Development,

Check failure on line 13 in client/src/services/environment.ts

View workflow job for this annotation

GitHub Actions / ⚡ Package web app

This line has a length of 143. Maximum allowed is 140

Check failure on line 13 in client/src/services/environment.ts

View workflow job for this annotation

GitHub Actions / web / 🌐 Web tests

This line has a length of 143. Maximum allowed is 140
};
}
return { key: DEFAULT_STRIPE_API_KEY, mode: EnvironmentType.Production };
return { key: DEFAULT_STRIPE_API_KEY, mode: EnvironmentType.Development };
}

const BMS_ENV_VARIABLE = 'VITE_BMS_API_URL';
const DEFAULT_BMS_URL = 'https://bms.parsec.cloud';
const DEFAULT_BMS_URL = 'https://bms-dev.parsec.cloud';

function getBmsUrl(): string {
if (import.meta.env[BMS_ENV_VARIABLE]) {
Expand All @@ -24,7 +27,7 @@ function getBmsUrl(): string {
}

const SIGN_ENV_VARIABLE = 'VITE_SIGN_URL';
const DEFAULT_SIGN_URL = 'https://sign.parsec.cloud';
const DEFAULT_SIGN_URL = 'https://sign-dev.parsec.cloud';

function getSignUrl(): string {
if (import.meta.env[SIGN_ENV_VARIABLE]) {
Expand Down

0 comments on commit 4d45f1a

Please sign in to comment.