azat-co / expressworks

Learn Express.js from the author of one of the best books on Express.js—Pro Express.js— with this workshop that will teach you basics of Express.js.
MIT License
709 stars 220 forks source link

STATIC - confused about instructions - where to learn more #98

Closed bessieatrazoyo closed 8 years ago

bessieatrazoyo commented 8 years ago

I am finding the ExpressWorks instructions incomprehensible. Perhaps I am missing some prerequisites. I’ve written out my questions below to show the level of ignorance I am coming to this learning session with. If you have suggestions about where to go to learn what I need before I start, please let me know.

For example, Exercise 2 of 8 (static) says:

Please don't use ANY routes like app.get. ONLY static.

I wonder:

  1. What is a route?
  2. How can I learn about app?
  3. Static? Static as opposed to dynamic. What does that mean?

Your solution must listen on the port number supplied by process.argv[2].

I wonder:

  1. What listens?
  2. Is this like the Hello World one where I used this: var app = express(); ... app.listen(process.argv[2]);

This is how you can call static middleware:

I wonder:

  1. What is static middleware?
  2. Where can I learn about it?

For this exercise expressworks will pass you the path:

app.use(express.static(process.argv[3] || path.join(__dirname, 'public')))

I wonder:

  1. Is app var app = express();?
  2. If so, what is express?
  3. Where did the path variable come from?

This what I think is supposed to happen: process.argv[3] points to an HTML file. I am supposed get this HTML file and send it back in a response. I’m supposed to wait for a request from process.argv[2], but I don’t know if I’m supposed to parse that request in any way.

TylerMoeller commented 8 years ago

The best place to start is with the command: expressworks help

This will give you a link to the API documentation and another to a book written by azat-co.

API docs: http://expressjs.com/api.html Express.js Guide: http://expressjsguide.com

The API docs should answer your questions:

Hope this helps.

bessieatrazoyo commented 8 years ago

Thank you very much the links to expressjs.com is what I was looking for. It will be a while before I can get back to it, but I'll post how it went when I do. Keep it open for now.

bessieatrazoyo commented 8 years ago

Evan Hahn's blog post: http://evanhahn.com/understanding-express/ helped me out.

azat-co commented 8 years ago

@TylerMoeller thanks ;)