Where the course ends and what to build next

The course ends with a package that answers a search over HTTP. Three projects were built over fourteen lessons, each one from the pieces of the parts before it, and the last lesson looks at what is there: the three programs side by side, the twelve parts of the course, the final run of the tests and the linter, and the work that follows.

Nothing new is written here. The value of a last lesson is the view from the top: a reader who has followed the course has a tracker, a search and a server, and the three of them are small enough to be read in an evening and complete enough to be changed.

The three projects

The table is the whole part in one screen. Each project has a value of its own, a way of storing it and one thing that the project is really about: a file that survives a crash, a map that turns a word into documents, and a protocol that lets another program ask.

Project Lessons What it does The value at the centre What it teaches
tasks 124 to 129 keeps a task list in a JSON file and changes it from four commands a Task that is valid by construction a model, an atomic write, argument parsing and two statuses
search 130 to 133 turns text into words and words into the documents that hold them a Map from a term to a list of ids a tokenizer, an inverted index, a score and a stable order
search-http 134 to 136 answers a search over HTTP and ships as a command a handler that takes the documents a route, a JSON answer, two error statuses and a tarball

The three folders do not depend on each other at run time. search-http holds a copy of the modules of search, which is a snapshot: a change to the ranking has to be made twice until the search becomes a package with a version, and that is the first exercise below.

The course in one page

The twelve parts of the course, in the order they were written. The last one is the part this lesson ends, and every part before it is the answer to a question that one of the three projects asked.

Part Lessons What it covers
Getting started 001 to 010 the runtime, the first program, the types, the operators and the first loops
Values, references and scope 011 to 022 one object under two names, the copies, const, closures and this
Strings, numbers and text 023 to 034 the numbers, the strings, the regular expressions, JSON and Intl
Functions and higher-order code 035 to 048 the parameters, the callbacks, map, filter and reduce, and the pipeline
Arrays and collections 049 to 060 the array methods, the sort, Map, Set and the choice between them
Objects, classes and modules 061 to 072 the descriptors, the prototypes, the classes and the two module systems
Errors, tests and debugging 073 to 078 throw and catch, the error classes, node:assert and the inspector
Asynchronous code 079 to 088 the event loop, the promises, async and await, the queues and the emitters
Files, processes and the network 089 to 102 the file system, the streams, the child processes, HTTP, the workers and the hashes
The browser and the DOM 103 to 110 the window, the selectors, the events, the forms and the storage
Tooling: npm, linting and formatting 111 to 122 the manifest, the scripts, the versions, ESLint, Prettier and npm pack
Capstone projects 123 to 136 this part: the tracker, the index and the endpoint

The order of the parts is not the order of a reference manual. It is the order in which a question can be answered with what the reader already has, which is why the promises arrive before the files and the files before the HTTP server.

The final state

The folder of project C holds eleven files. Five sit under src, two are the tests, two are the command and the probe, and two are the manifest and the lint config.

The folder search-http:

search-http/ bin/search-serve.js the command of the package server.js the probe, out of the tarball src/handler.js the route and the JSON answer src/index.js the inverted index src/query.js the ranking src/search.js the facade src/tokenizer.js text to words test/search.test.js test/tokenizer.test.js eslint.config.js package.json

The two scripts of the manifest are the check of the project. The test script runs the twelve tests with the dot reporter and the lint script runs the linter over the whole folder, and the two of them are what a pipeline runs before it publishes anything.

npm test
npm run lint
echo "the exit status: $?"


> search-http@1.0.0 test
> node --test --test-reporter=dot

............

> search-http@1.0.0 lint
> eslint .

the exit status: 0

Twelve dots and a zero, then the second script with nothing to say and the same zero at the end. The blank lines are npm announcing the script it is about to run, which is useful at a terminal and silenced by --silent in a chain of checks.

That is the state the course leaves the reader in: a folder where the tests pass, the linter is quiet and one command starts an endpoint.

Where to go next

The three projects are a base and not a product, and the way from one to the other is a list of questions that the code already asks. The first is the corpus: three documents in a constant become a folder that the program reads, with a tokenizer that handles accents, a stop list for the language and a check that the build of a thousand files is still fast.

The second is storage. A JSON file read into memory is right for a list of tasks and wrong for a corpus that does not fit, and the answer is a database with an index of its own. The third is the browser: the endpoint of project C is exactly what a page needs, and the lesson on fetch in the browser is the first half of that page.

The fourth is the package. search-http is one npm publish away from being installed by somebody else, and the three fields that decide it are in its manifest. A version, a readme and a licence are the difference between a folder and a dependency that another person can trust.

The Rust course of this site ends the same way, with three capstones and a benchmark, and a reader who wants the same projects in another language finds the parallel in the Rust course. The pieces are different and the shape of a project is not.

The course page lists every lesson that is written, and the JavaScript hub holds the articles that are not part of the course: the frameworks, the tools and the notes.

Exercises

  1. Give the search a package of its own and install it into search-http with a file: dependency. Which two folders change, and which one keeps a copy?
  2. Read the documents from a folder instead of a constant, with one file per document. Which function of the facade changes, and which test has to build a folder?
  3. Add a limit parameter to the endpoint that cuts the results to the first n. Which layer does the cut belong to, and which status does a limit of zero get?
  4. Write the readme of search-http with the installation, one example of the endpoint and one line about the tests. Which of the three files of a package is still missing?
  5. Take the tracker of project A and give it the endpoint of project C: which three functions of the tracker would the routes call, and which one would need a body?

Questions

A new set of questions in a new order every time. Choose one answer for each, then check.

  1. Which three projects does the course build?

    Answer

    A task tracker, a search index and the index over HTTP

    The last part puts the pieces of the course into three programs of increasing reach.

  2. What does this program print? const projects = ["tasks", "search", "search-http"]; console.log(projects.length + " projects: " + projects.join(", "));

    Answer

    3 projects: tasks, search, search-http

    The length is three and the join puts a comma and a space between the names.

  3. Which project does not depend on another at run time?

    Answer

    tasks, because it has its own model and storage

    The tracker was built from nothing, while the other two share the search modules.

  4. What does this program print? const parts = 12; const last = 136; console.log(parts + " parts, the last lesson is " + last);

    Answer

    12 parts, the last lesson is 136

    The two numbers are fields of the line and the rest is text.

  5. What does npm test run in this project?

    Answer

    The test script of the manifest, which runs node --test

    The command reads the scripts table, and the entry named test is the test runner.

  6. What does this program print? const scripts = { test: "node --test", lint: "eslint ." }; console.log(Object.keys(scripts).join(" and "));

    Answer

    test and lint

    The keys are the names a reader types after npm run.

  7. Which file of a package is still missing when it has a manifest, a readme and a licence?

    Answer

    None, those three are the whole set

    A registry page needs a name, a description and a licence, and the readme is the description.

  8. What does this program print? const hits = [{ id: 1 }, { id: 2 }, { id: 3 }]; const limited = hits.slice(0, 2); console.log(limited.length, hits.length);

    Answer

    2 3

    The slice copies the first two entries and leaves the array as it was.

  9. Why does the search have to become a package before the copy goes away?

    Answer

    So the endpoint depends on a version instead of on a snapshot of the files

    A dependency with a version can be updated once; a copy has to be fixed in every place it lives.

  10. What does this program print? const text = "the end"; console.log(text.split(" ").map((word) => word.toUpperCase()).join("-"));

    Answer

    THE-END

    Each word is upper-cased and the two are joined by a dash.

The programs and commands on this page were run with Node.js 24.22.1 and npm 11.12.1, and linted with ESLint 10.14.0 on Alpine Linux 3.24.3 (x86_64) in a Docker container.

Article author: Arthur Isaev