freeCodeCamp/api
2025-09-29 18:56:29 +05:30
..
__mocks__ feat(api): migrate to esm (#61915) 2025-09-19 13:28:06 +05:30
prisma feat(api): add exam->challenge map and routes (#61683) 2025-09-18 15:32:44 +02:00
src fix(api): 400 for exam-challenge route with no params (#62404) 2025-09-29 18:56:29 +05:30
tools feat(api): migrate to esm (#61915) 2025-09-19 13:28:06 +05:30
.gitignore feat: create docker images for new api (#51538) 2023-09-13 02:15:25 +05:30
package.json feat(api): migrate to esm (#61915) 2025-09-19 13:28:06 +05:30
README.md chore(api): add exam-env test script (#60445) 2025-05-27 09:53:51 +05:30
tsconfig.build.json refactor(api): organise tooling (#59931) 2025-04-24 10:27:23 +05:30
tsconfig.json feat(api): migrate to esm (#61915) 2025-09-19 13:28:06 +05:30
vitest.utils.test.ts feat(api): migrate to esm (#61915) 2025-09-19 13:28:06 +05:30
vitest.utils.ts refactor: remove jest and lint vitest (#62330) 2025-09-24 09:27:03 +02:00

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>