Skip to content
Open
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
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ FCC_ENABLE_DEV_LOGIN_MODE=true

# Student progress data. The mock server (pnpm run mock-fcc-data) is the default.
# Set FCC_API_URL and TPA_API_BEARER_TOKEN to use the freeCodeCamp API instead.
# Production requires FCC_API_URL.
MOCK_USER_DATA_URL=http://localhost:3002/data
FCC_API_URL=
TPA_API_BEARER_TOKEN=
Expand Down
9 changes: 8 additions & 1 deletion __tests__/utils/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
NEXTAUTH_SECRET: 'test-production-secret',
AUTH0_DOMAIN: 'example.auth0.com',
AUTH0_CLIENT_ID: 'test-client-id',
AUTH0_CLIENT_SECRET: 'test-client-secret'
AUTH0_CLIENT_SECRET: 'test-client-secret',
// TODO: replace with the real freeCodeCamp API URL once it is confirmed

Check notice on line 19 in __tests__/utils/env.test.ts

View check run for this annotation

codefactor.io / CodeFactor

__tests__/utils/env.test.ts#L19

Unexpected 'todo' comment: 'TODO: replace with the real freeCodeCamp...'. (no-warning-comments)
FCC_API_URL: 'https://api.example.org'
};

describe('findEnvProblems', () => {
Expand Down Expand Up @@ -64,6 +66,11 @@
]);
});

it('requires FCC_API_URL in production', () => {
const env: NodeJS.ProcessEnv = { ...productionEnv, FCC_API_URL: undefined };
expect(findEnvProblems(env)).toEqual(['FCC_API_URL is not set']);
});

it('rejects dev login mode in production', () => {
const env: NodeJS.ProcessEnv = {
...productionEnv,
Expand Down
3 changes: 2 additions & 1 deletion util/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const ALWAYS_REQUIRED: string[] = [
const PRODUCTION_REQUIRED: string[] = [
'AUTH0_DOMAIN',
'AUTH0_CLIENT_ID',
'AUTH0_CLIENT_SECRET'
'AUTH0_CLIENT_SECRET',
'FCC_API_URL'
];

export function findEnvProblems(env: NodeJS.ProcessEnv): string[] {
Expand Down
Loading