mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-05 21:04:28 +08:00
|
Some checks failed
i18n - Build Validation / Validate i18n Builds (22) (push) Has been cancelled
CI - Node.js / Lint (22) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Build Client (22) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Build API (Container) (push) Has been cancelled
CI - Node.js / Build (22) (push) Has been cancelled
CI - Node.js / Test (22) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (22) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Run Playwright 3rd Party Donation Tests (chromium, 22) (push) Has been cancelled
|
||
|---|---|---|
| .. | ||
| __mocks__ | ||
| prisma | ||
| src | ||
| tools | ||
| .gitignore | ||
| package.json | ||
| prisma.config.ts | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| vitest.utils.test.ts | ||
| vitest.utils.ts | ||
Working on the new api
Connecting to local database
The api uses the ORM Prisma and it needs the MongoDB instance to be a replica set.
Atlas
If you use MongoDB Atlas, the set is managed for you.
Local
The simplest way to run a replica set locally is to use the docker-compose file in /tools.
cd tools
docker compose up -d
The new db will be empty, so you can run the seed script to populate it.
cd ../.. # back to the root of the repo
pnpm seed
Troubleshooting
If you have any issues connecting to the database (e.g. MongoServerError: not primary), try removing the volume and recreating the containers.
cd tools
docker compose down -v
docker compose up -d
Login in development/testing
During development and testing, the api exposes the endpoint GET auth/dev-callback. Calling this will log you in as the user with the email foo@bar.com by setting the session cookie for that user.
Generating Exams
pnpm run exam-env:generate <ENV_EXAM_ID> <NUMBER_OF_EXAMS_TO_GENERATE>