🌍 freeCodeCamp · subject

freeCodeCamp Back End Development and APIs Syllabus

The Back End Development and APIs syllabus for freeCodeCamp in full: 5 chapters and 17 topics, every one listed below, plus 50 Back End Development and APIs flashcards with answers.

5Chapters
17Topics
50Flashcards

Back End Development and APIs syllabus: all 5 chapters

Expand any chapter to see its topics and sub-topics.

  1. Managing Packages with npm

    2 topics
    • package.json
    • Dependencies and Scripts
  2. Node.js and Express

    4 topics
    • Serving Files and Routes
    • Middleware
    • Handling POST and Query Data
    • Environment Variables
  3. MongoDB and Mongoose

    3 topics
    • Schemas and Models
    • CRUD Operations
    • Queries and Chaining
  4. Building Web APIs

    3 topics
    • RESTful Design
    • JSON Responses
    • Request Parsing
  5. Certification Projects

    5 topics
    • Timestamp Microservice
    • Request Header Parser
    • URL Shortener Microservice
    • Exercise Tracker
    • File Metadata Microservice

freeCodeCamp Back End Development and APIs flashcards — 50 questions with answers

  1. What is the purpose of the package.json file in a Node.js project?

    It is the central configuration file of a Node.js project: a JSON document at the project root that stores metadata (name, version, description, author, license) and lists dependencies and scripts, allowing npm to install and manage the project.

  2. Which two fields are the only mandatory fields in package.json?

    "name" and "version". Every package.json must include both for npm to publish or manage the package.

  3. In package.json, what is the difference between "dependencies" and "devDependencies"?

    "dependencies" lists packages required at runtime in production; "devDependencies" lists packages needed only during development and testing (e.g., linters, test frameworks). Production installs (npm install --production) skip devDependencies.

  4. In semantic versioning "MAJOR.MINOR.PATCH", what does each number represent?

    MAJOR changes when there are incompatible/breaking API changes, MINOR when functionality is added in a backward-compatible way, and PATCH when backward-compatible bug fixes are made.

  5. What do the tilde (~) and caret (^) prefixes mean in a package.json dependency version like ~1.2.3 or ^1.2.3?

    ~1.2.3 allows only patch updates (any 1.2.x). ^1.2.3 allows minor and patch updates (any 1.x.x) but not a new major version. No prefix pins the exact version.

  6. What does the "scripts" section of package.json do, and how do you run a script named "start"?

    It defines named shell commands for the project (build, test, start, etc.). Run them with npm run <name>; "start" and "test" are special and can be run directly as npm start or npm test.

  7. How do you create a basic Express application and start it listening on port 3000?

    const express = require('express'); const app = express(); then app.listen(3000) starts the server. Route handlers are attached to app before listening.

  8. In Express, how do you respond to a GET request at the root path with the string "Hello Express"?

    app.get('/', (req, res) => res.send('Hello Express')); — app.get registers a handler for GET requests at the given path, and res.send() sends a string response.

  9. How does an Express server send a file (e.g., an HTML page) as a response?

    With res.sendFile(path), which requires an absolute path — conventionally built as __dirname + '/views/index.html'. It sets the correct Content-Type based on the file extension.

  10. How do you serve static assets (CSS, images, scripts) from a folder called "public" in Express?

    Mount the built-in static middleware: app.use('/public', express.static(__dirname + '/public')); Files in the folder are then served directly at the /public path.

  11. What is middleware in Express?

    A function with signature (req, res, next) that executes during the request-response cycle. It can inspect or modify req and res, end the response, or call next() to pass control to the next middleware/handler in the chain.

  12. What happens if an Express middleware function neither sends a response nor calls next()?

    The request hangs: the response is never completed and the client eventually times out, because control is never passed on and nothing ends the cycle.

  13. What is the difference between app.use() and app.get() when mounting middleware in Express?

    app.use() mounts middleware for all HTTP methods (optionally restricted to a path prefix), while app.get() (and app.post(), etc.) attaches a handler only for that specific HTTP method and exact route.

  14. Why does the order in which middleware is mounted matter in Express?

    Express executes middleware in the order it is mounted. A middleware mounted after a route will never run for that route, so things like loggers and body parsers must be mounted before the routes that need them.

  15. How do you chain multiple handlers on a single route in Express?

    Pass them in sequence, e.g. app.get('/user', middlewareFn, finalHandler). Each middleware calls next() to hand off; data can be shared by attaching properties to the req object.

  16. In Express, what is the difference between route parameters (req.params) and query parameters (req.query)?

    Route parameters are named segments of the path defined with a colon (e.g., /user/:id gives req.params.id). Query parameters come after the ? in the URL (e.g., ?name=John gives req.query.name) and are typically optional key-value filters.

  17. For the URL GET /name?first=John&last=Doe, how do you access "John" and "Doe" in an Express handler?

    req.query.first returns "John" and req.query.last returns "Doe" — Express parses the query string into the req.query object automatically.

  18. What middleware is required in modern Express to read URL-encoded form data and JSON bodies from POST requests?

    app.use(express.urlencoded({ extended: false })) for HTML form data and app.use(express.json()) for JSON bodies. (Older tutorials use the body-parser package, which these built-ins replaced.) The parsed data appears on req.body.

  19. Where does data sent by an HTML form with method="POST" appear in an Express handler, and what is needed for it to be there?

    On req.body (e.g., req.body.first), but only after body-parsing middleware such as express.urlencoded() has been mounted before the route; otherwise req.body is undefined.

  20. What are environment variables and why are they used instead of hard-coding configuration?

    They are key-value pairs provided by the operating environment (accessed in Node via process.env.VAR_NAME). They keep secrets (API keys, database URIs) and environment-specific settings (ports, modes) out of source code, so the same code runs in dev and production with different configs.

Show the other 30 Back End Development and APIs flashcards
  1. What does the dotenv package do, and how do you use it?

    It loads variables from a .env file into process.env. Call require('dotenv').config() at the very top of the entry file; the .env file should be listed in .gitignore so secrets are never committed.

  2. What are two syntax rules for defining variables in a .env file?

    Use KEY=value with no spaces around the equals sign, and no quotes around the value; by convention keys are UPPERCASE with words separated by underscores. All values are read as strings.

  3. What is MongoDB and what is Mongoose in relation to it?

    MongoDB is a NoSQL document database that stores JSON-like documents in collections. Mongoose is an ODM (Object Data Modeling) library for Node.js that adds schemas, models, validation, and a query API on top of MongoDB.

  4. In Mongoose, what is the difference between a Schema and a Model?

    A Schema defines the shape of documents (fields, types, defaults, validators). A Model is a constructor compiled from a schema with mongoose.model('Name', schema); model instances are documents that can be saved to and queried from the database.

  5. How do you connect to a MongoDB database with Mongoose using an environment variable?

    mongoose.connect(process.env.MONGO_URI) — the connection string (Atlas URI) is stored in an environment variable rather than hard-coded, and options like useNewUrlParser/useUnifiedTopology were passed in older versions.

  6. Write a Mongoose schema for a Person with a required string name, a number age, and an array of string favoriteFoods.

    const personSchema = new mongoose.Schema({ name: { type: String, required: true }, age: Number, favoriteFoods: [String] }); then const Person = mongoose.model('Person', personSchema);

  7. What does CRUD stand for, and which Mongoose methods commonly implement each operation?

    Create, Read, Update, Delete. Create: document.save() or Model.create(); Read: Model.find(), findOne(), findById(); Update: Model.findByIdAndUpdate() or findOneAndUpdate(); Delete: Model.findByIdAndDelete()/findByIdAndRemove() or Model.deleteMany().

  8. In Mongoose, what is the difference between Model.find(), Model.findOne(), and Model.findById()?

    find() returns an array of all documents matching the filter; findOne() returns only the first matching document (or null); findById(id) is shorthand for findOne({ _id: id }) and returns the single document with that _id.

  9. When using Model.findByIdAndUpdate() in Mongoose, what option must you pass to receive the updated document instead of the original?

    { new: true }. By default findByIdAndUpdate returns the document as it was before the update; new: true makes it return the modified document.

  10. How do you build a chained Mongoose query that finds people who like burritos, sorts by name, limits to 2 results, and hides the age field?

    Person.find({ favoriteFoods: 'burrito' }).sort({ name: 1 }).limit(2).select('-age').exec(callback) — chaining builds the query, and exec() (or await) runs it. In sort(), 1 means ascending and -1 descending.

  11. What is a RESTful API?

    An API following REST (Representational State Transfer) conventions: resources are identified by URLs, standard HTTP methods (GET, POST, PUT/PATCH, DELETE) express operations on them, requests are stateless, and responses commonly use JSON.

  12. Match the four main HTTP methods to their CRUD operations and state their key properties.

    POST → Create (not idempotent); GET → Read (safe and idempotent, no body changes); PUT/PATCH → Update (PUT replaces the whole resource and is idempotent, PATCH modifies part of it); DELETE → Delete (idempotent).

  13. What does it mean that HTTP/REST is "stateless"?

    Each request must contain all information the server needs to handle it; the server stores no client session context between requests, so any request can be understood in isolation.

  14. What do the HTTP status code classes 2xx, 3xx, 4xx, and 5xx indicate, and what do 200, 201, 404, and 500 specifically mean?

    2xx = success, 3xx = redirection, 4xx = client error, 5xx = server error. 200 OK = successful request, 201 Created = resource created, 404 Not Found = resource doesn't exist, 500 Internal Server Error = server-side failure.

  15. How do you send a JSON response in Express, and what header does it set?

    res.json(object) serializes the JavaScript object to JSON and sends it with the Content-Type header set to application/json; e.g., res.json({ message: 'Hello json' }).

  16. In a Node/Express app, what is "request parsing" and which req properties hold the parsed pieces of a request?

    Extracting structured data from an incoming HTTP request: req.params for route path segments, req.query for the query string, req.body for the parsed body (requires body-parsing middleware), req.headers for HTTP headers, and req.ip for the client's IP address.

  17. Timestamp Microservice: given a valid date, what JSON must the API return for GET /api/:date?

    { unix: <milliseconds since Unix epoch as a Number>, utc: <date as a UTC string, e.g. "Thu, 01 Jan 1970 00:00:00 GMT"> } — unix comes from date.getTime() and utc from date.toUTCString().

  18. Timestamp Microservice: how must the API behave for an empty date parameter and for an invalid date?

    An empty /api/ request returns the current time in the same { unix, utc } format; an invalid date (where new Date(input) yields Invalid Date) returns { error: "Invalid Date" }.

  19. Timestamp Microservice: why must a numeric date parameter like "1451001600000" be handled specially before passing it to new Date()?

    Because new Date("1451001600000") on a string treats it as a date string and fails, while a Unix timestamp must be passed as a Number of milliseconds: new Date(parseInt(param)). Code typically checks /^\d+$/ to decide.

  20. What is the Unix epoch, and in what unit does JavaScript's Date.getTime() measure time from it?

    The Unix epoch is 00:00:00 UTC on 1 January 1970. JavaScript's getTime() returns milliseconds since the epoch (whereas classic Unix time counts seconds, so seconds = ms / 1000).

  21. Request Header Parser Microservice: what JSON does GET /api/whoami return, and where does each value come from?

    { ipaddress, language, software }: ipaddress from req.ip (or the x-forwarded-for header behind a proxy), language from the accept-language request header, and software from the user-agent request header.

  22. URL Shortener Microservice: describe the two endpoints and their responses.

    POST /api/shorturl with a URL in the body stores it and returns { original_url: <url>, short_url: <number> }. GET /api/shorturl/<short_url> looks up the stored original URL and redirects (res.redirect) to it.

  23. URL Shortener Microservice: how are invalid URLs handled, and what is a common validation technique?

    Invalid input must return { error: 'invalid url' }. Validation typically parses the URL (checking for a valid http:// or https:// format) and/or uses dns.lookup() on the hostname to verify it resolves.

  24. Exercise Tracker: what does POST /api/users do and what does it return?

    It creates a new user from a form field "username" and returns an object with the username and the database-generated _id: { username, _id }. GET /api/users returns an array of all such user objects.

  25. Exercise Tracker: what fields does POST /api/users/:_id/exercises accept, and what does the response look like?

    It accepts description (string), duration (number of minutes), and an optional date (defaults to the current date if omitted). It returns the user object with the exercise fields added: { _id, username, date, duration, description }, where date is formatted with toDateString().

  26. Exercise Tracker: what does GET /api/users/:_id/logs return, and what do the from, to, and limit query parameters do?

    It returns { username, count, _id, log } where log is an array of { description, duration, date } objects and count is the total number of exercises. from and to filter the log by date range (yyyy-mm-dd), and limit caps how many log entries are returned.

  27. In the Exercise Tracker log, what types must description, duration, and date have?

    description must be a String, duration must be a Number, and date must be a String in the format produced by Date.prototype.toDateString() (e.g., "Mon Jan 01 1990").

  28. File Metadata Microservice: what npm package handles the file upload, and how is it wired into the route?

    multer. It is used as route middleware, e.g. app.post('/api/fileanalyse', upload.single('upfile'), handler), where 'upfile' is the form field name; multer puts the file's info on req.file.

  29. File Metadata Microservice: what JSON does POST /api/fileanalyse return, and from which req.file properties?

    { name, type, size } taken from req.file.originalname (file name), req.file.mimetype (MIME type), and req.file.size (size in bytes).

  30. Why do HTML forms that upload files use enctype="multipart/form-data", and why can't express.urlencoded() parse them?

    multipart/form-data encodes the body in multiple parts so binary file contents can be transmitted alongside text fields; express.urlencoded()/express.json() only parse text-based bodies, so a multipart parser like multer is required to extract the file.

freeCodeCamp Back End Development and APIs FAQ

What is in the freeCodeCamp Back End Development and APIs syllabus?

freeCodeCamp Back End Development and APIs is split into 5 chapters: Managing Packages with npm, Node.js and Express, MongoDB and Mongoose, Building Web APIs and Certification Projects. Together they contain 17 topics.

How many chapters are in freeCodeCamp Back End Development and APIs?

5 chapters, containing 17 topics. The largest chapter is Certification Projects, with 5 topics.

Are there flashcards for freeCodeCamp Back End Development and APIs?

Yes — a 50-card Back End Development and APIs deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.