

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Web Servers
incomplete
2: Async TypeScript
incomplete
3: Setup
incomplete
4: Build
incomplete
5: Server
incomplete
6: Fileservers
incomplete
7: Fileserver Quiz
incomplete
8: Serving Images
incomplete
9: Workflow Tips
incomplete
10: Custom Handlers
incomplete
11: Request, Response
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Servers are interesting because they're always running. A lot of the code we've written in Boot.dev up to this point has acted more like a command line tool: it runs, does its thing, and then exits.
Servers are different. They run forever, waiting for requests to come in, processing them, sending responses, and then waiting for the next request. If they didn't work this way, websites and apps would be down and unavailable all the time!
Debugging a CLI app is simple:
Debugging a server is a little different. The simplest way (minimal tooling) is to:
Make sure you're testing your server by hitting endpoints in the browser before submitting your answers.
I like to add scripts to package.json to make it easier to start the server (which we did earlier).
{
...
"scripts": {
"dev": "npx tsc && node dist/index.js"
},
...
}
This way, I can just run npm run dev to compile and start the server.
To stop the server, I use Ctrl+C. This sends a signal to the server, telling it to stop. The server then exits.
To start it again, I just run the same command.
If you didn't know, you can continuously press the ↑ key on the command line to see the commands you've previously run. That way you don't need to retype commands that you use often!