freeCodeCamp/api
Mrugesh Mohapatra ef610dd36c
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
fix(tools): s/MailHog/Mailpit/g (#62481)
2025-10-03 13:25:33 -07:00
..
__mocks__ chore(api): remove vitest import from mock (#62478) 2025-10-03 19:42:25 +05:30
prisma feat(api): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +02:00
src fix(tools): s/MailHog/Mailpit/g (#62481) 2025-10-03 13:25:33 -07:00
tools feat(api): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +02:00
.gitignore feat: create docker images for new api (#51538) 2023-09-13 02:15:25 +05:30
package.json feat(api): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +02:00
prisma.config.ts feat(api): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +02:00
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): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +02:00
vitest.utils.ts feat(api): exam date use + split prisma files (#62344) 2025-10-02 14:28:36 +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>