### Run All Development Servers with Turbo Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp Use this command to start all development servers simultaneously within the monorepo. Ensure all necessary dependencies are installed. ```bash pnpm run develop ``` -------------------------------- ### Curriculum File Structure Example Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/5-curriculum Illustrates the directory structure for curriculum content, including challenges, structure definitions, and build scripts. ```directory structure curriculum/ ├── challenges/ # Challenge markdown files │ └── english/ # English language source │ └── [block]/ # e.g., lab-nth-fibonacci-number-js │ └── [id].md # Individual challenge file ├── structure/ # Curriculum structure definitions │ ├── curriculum.json # Lists all SuperBlocks and Certifications │ └── superblocks/ # SuperBlock structure files │ └── *.json # e.g., javascript-v9.json └── src/ # Build scripts └── build-curriculum.ts # Orchestrates the curriculum build ``` -------------------------------- ### Database Seeding Script Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture In development, the database can be seeded using scripts located in `tools/scripts/seed/`. This ensures a consistent starting state for the database during local development. ```bash pnpm --filter @freecodecamp/api seed:db ``` -------------------------------- ### API Schema Validation with TypeBox Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The API server uses TypeBox for schema validation, ensuring data integrity for incoming requests. This example shows a basic schema definition. ```typescript import { Type, Static } from '@sinclair/typebox'; export const UserSchema = Type.Object({ username: Type.String(), email: Type.String({ format: 'email' }), }); export type User = Static; ``` -------------------------------- ### Build All Packages with Turbo Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp Execute this command to build all packages within the monorepo. This is typically used for production deployments. ```bash pnpm run build ``` -------------------------------- ### Seed Development Database with Turbo Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp Use this command to seed the development database. This is helpful for populating the database with initial data for testing or development. ```bash pnpm run seed ``` -------------------------------- ### API Server Instantiation and Configuration Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The API server is instantiated using the `build` function in `api/src/app.ts`. It utilizes Fastify and Prisma for data access, with configuration managed via environment variables. ```typescript import { build } from "./app"; const server = build({ // ... options }); server.listen(3000, (err, address) => { if (err) { server.log.error(err); process.exit(1); } server.log.info(`Server listening at ${address}`); }); ``` -------------------------------- ### Fastify Instance Creation with TypeBox Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/4-api-server Creates a Fastify instance configured with TypeBox for type-safe request/response schemas. This is the primary method for initializing the API server. ```typescript const fastify = Fastify(options).withTypeProvider(); ``` -------------------------------- ### Run All Tests with Turbo Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp This command runs all tests across all packages in the monorepo. It's crucial for ensuring code quality and stability. ```bash pnpm run test ``` -------------------------------- ### Monorepo Build Orchestration with Turbo Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The root package.json orchestrates builds across all monorepo packages using Turbo. This command initiates a build process that resolves dependencies between client, curriculum, and API packages. ```bash pnpm build # Executes turbo build ``` -------------------------------- ### Monorepo Development Commands Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/1-overview Unified commands for developing the monorepo using Turbo. These commands streamline common development tasks across all packages. ```bash pnpm run develop pnpm run build pnpm run test pnpm run seed ``` -------------------------------- ### Environment Variable Configuration Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The system relies on a `.env` file for local configuration, which is validated at runtime by the API. Key services like Auth0, Stripe, and email providers are configured through these variables. ```dotenv AUTH0_DOMAIN=your-auth0-domain.auth0.com STRIPE_SECRET_KEY=sk_test_... MONGOHQ_URL=mongodb://localhost:27017/freecodecamp ``` -------------------------------- ### Monorepo Workspace Links Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The monorepo utilizes workspace links to facilitate code sharing between packages. This allows packages like `@freecodecamp/client` and `@freecodecamp/api` to depend on shared utilities. ```bash pnpm --filter @freecodecamp/client add @freecodecamp/shared ``` -------------------------------- ### PR Checklist Verification Script Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/7-contributing-guide This JavaScript script verifies that the first three checkboxes in the PR template are ticked. It's used by GitHub Actions to ensure essential contribution guidelines are followed. ```javascript const core = require("@actions/core"); const github = require("@actions/github"); const PR_TEMPLATE_PATH = ".github/pull_request_template.md"; async function checkPrTemplate() { const octokit = github.getOctokit(process.env.GITHUB_TOKEN); const context = github.context; if (context.eventName !== "pull_request") { core.setFailed("This action can only be run on pull requests."); return; } const { owner, repo } = context.repo; const prNumber = context.issue.number; try { const { data: pr } = await octokit.rest.pulls.get({ owner, repo, pull_number: prNumber, }); const prBody = pr.body; if (!prBody) { core.setFailed("PR body is empty. Please include the PR template."); return; } const requiredCheckboxes = [ "I have read and followed the contribution guidelines", "I have read and followed the how to open a pull request guide", "My pull request targets the `main` branch", ]; for (const checkbox of requiredCheckboxes) { if (!prBody.includes(`- [x] ${checkbox}`)) { core.setFailed(`PR template is missing required checkbox: ${checkbox}`); return; } } core.info("PR template checklist verified successfully."); } catch (error) { core.setFailed(`Error checking PR template: ${error.message}`); } } checkPrTemplate(); ``` -------------------------------- ### Data Layer Prisma Plugin Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture The data layer integrates MongoDB with Prisma ORM. The connection is managed via the `prismaPlugin`, which is typically registered with the Fastify server. ```typescript import fastifyPrisma from '@fastify/prisma'; fastify.register(fastifyPrisma, { // ... prisma options }); ``` -------------------------------- ### API Route Protection Hooks Source: https://deepwiki.com/freeCodeCamp/freeCodeCamp/2-system-architecture Protected API routes are secured using Fastify hooks like `fastify.authorize` and `fastify.csrfProtection`. These hooks ensure proper authentication and authorization before processing requests. ```typescript fastify.route({ method: 'POST', url: '/protected-resource', preHandler: [fastify.authorize, fastify.csrfProtection], handler: async (request, reply) => { // ... protected logic } }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.