# Node.js Studio — runnable starter

Use an officially supported Node.js release, minimum Node 22. Verify with `node --version`. Extract nodejs-starter.zip and open a terminal inside its folder. All imports use Node built-ins: **no npm install step is required**.

## Four projects

1. **CLI:** `node cli.mjs Ada` → `Hello, Ada!`. Omit the name to see usage on stderr and exit code 1. Multiple words are joined as one name.
2. **File report:** `node report.mjs` → a JSON report with count 2 and total 15. The fixture is located relative to the module, so changing your working directory does not break it. Copy the project before editing its fixture to explore invalid input.
3. **API:** `npm start` → open `http://127.0.0.1:3000/health` or `/products`. A query string is ignored, not a filtering implementation. Unknown paths return 404; unsupported methods on known paths return 405 with Allow: GET. Stop with Ctrl+C. If port 3000 is busy, choose a different PORT in your shell (macOS/Linux: `PORT=3001 npm start`; PowerShell: `$env:PORT='3001'; npm start`). Startup validates the port and fixture. No writes, credentials, database or external service are involved.
4. **Tests:** `npm test` or `node --test`. Six named tests cover contract boundaries, port configuration, real CLI processes, module-relative file loading and HTTP requests. Tests use an available local port and close the server afterward.

## Files

- cli.mjs: command-line input, output and failure status.
- report.mjs: asynchronous file reading and reporting.
- lib/products.mjs: shared validation, summary and configuration functions.
- api.mjs: reusable read-only HTTP server factory.
- server.mjs: startup configuration and bounded local shutdown.
- products.test.mjs: executable tests with built-in tools.
- data/products.json: fictional fixture.

## Deliberate limits and extension ideas

The API reads its fixture at startup; restart after changing the file. It binds only to 127.0.0.1. It has no write endpoints, authentication, persistent database, TLS or production hosting setup. These are future design decisions, not hidden features. Prices are simple teaching numbers; define integer minor units/currency rules for real money.

Add a tested category filter, improve CLI usage, or add a report format option before attempting persistent writes. Keep untrusted file paths and request bodies out of the starter until you have designed size limits, validation and authorization.

The browser guide runs simulations and JavaScript data exercises. This downloaded project is the part that runs real Node.js. Running the tests does not update the website's learning progress automatically; record your results manually.
