freeCodeCamp/api
Mrugesh Mohapatra 16e461385e
Some checks failed
CI - E2E - 3rd party donation tests / Build Client (20) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Build API (Container) (push) Has been cancelled
CI - Node.js / Lint (20) (push) Has been cancelled
CI - E2E - 3rd party donation tests / Run Playwright 3rd Party Donation Tests (chromium, 20) (push) Has been cancelled
CI - Node.js / Build (20) (push) Has been cancelled
CI - Node.js / Test (20) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20) (push) Has been cancelled
chore(api-server): bye-bye you served us well (#60520)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2025-05-27 09:56:46 +05:30
..
__mocks__ chore(api): add env exam scripts (#58208) 2025-01-28 17:00:52 +01:00
prisma fix(api): handle string challengeType (#60491) 2025-05-23 18:26:18 +05:30
src fix(api): handle expected Auth0 errors (#60499) 2025-05-27 09:51:03 +05:30
tools chore(api): add exam-env test script (#60445) 2025-05-27 09:53:51 +05:30
.gitignore feat: create docker images for new api (#51538) 2023-09-13 02:15:25 +05:30
jest.config.ts test: speed up api tests (#53969) 2024-03-09 10:36:19 +05:30
jest.utils.test.ts test: minor fix to how cookies are passed around (#55259) 2024-06-21 08:36:46 -07:00
jest.utils.ts fix(api): handle users without email addresses (#60467) 2025-05-22 11:28:56 +02:00
package.json chore(api-server): bye-bye you served us well (#60520) 2025-05-27 09:56:46 +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 refactor(api): import ts-reset in entrypoint (#51677) 2023-09-28 09:40:51 -07: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>