cmda-bt / be-course-17-18

🎓 Backend · 2017-2018 · Curriculum and Syllabus 💾
Other
47 stars 19 forks source link

Listing assignment #473

Closed Maikxx closed 6 years ago

Maikxx commented 6 years ago

Hello again!

Link to repo

Although it isn't the most pretty code of codes, it packs the punch. I liked figuring out, how to get all of this to work from scratch (which resulted in a lot of conditionals haha). All and all a good exercise to really get a grasp on writing servers from scratch and what effort goes behind the big companies servers.

I cannot really think of any feedback, except for maybe putting the toolbox recommendations in the readme of the exercise, to make finding them easier haha! I had to go back in the presentation sheets a few times, because I forgot the names of the packages.

wooorm commented 6 years ago

Thanks for the cat Maik! 🐈

Some tips + tops:

Anyway, maybe this sounds negative, but you did an awesome job! 👍

Maikxx commented 6 years ago

Add private: true to package.json, that makes sure you don’t accidentally publish your package!

Thanks! I did not know about private: true. I will do that on all the upcoming projects that I don't want to publish.

Use repository: "Maikxx/HTTP_Server" in package.json if you’re linking to GH, it works!

Great tip! Will implement such things as well in the coming projects.

use lower-dash-case for repository names, it’s generally work beter, especially because windows and unix support casing differently

Yes, I know about the Windows, Unix differences, however I found myself working with this set up from the start, so changing it is cumbersome, but I will start trying with lower-dash-casing.

For links in markdown, you can do as well, if the URL should be the same as the link text

I did not know this! I was trying all kinds of different ways to make it work, but it didn't. Know I know how! =)

The goal for this assignment, I intended, was more to create something like serve than to actually use it directly, so: create a nice 404 page, and a nice listing page, with css and stuff! Currently, if I go to localhost:8000/images serve opens a new tab! Not the best of experiences...

Ah. I misinterpreted that then. I was looking for hours to find ways for serve to work on the same port, but I couldn't find a way, so I had to throw the towel in the ring for that one. About the 404 styling, I totally forgot that t.b.h.

The SIGTERM part is nice, but I believe servers are already closed by default if you CTRL+C a node process?

Well for some reason when I remove that piece of code, and my editor (with built in terminal, or iTerm) closes unexpectedly, I found myself having to deal with 'killing' the remaining node processes in order for this to restart. I am not entirely sure why that is, but that's why I kept it in.

The goal for this assignment was also not literally about assets or images, rather, about any directory you’d place somewhere! Your code now deals with these paths directly, but I was hoping you’d detect directories dynamically!

A classic case of misinterpreting, again, from my part...

Why fs.lstat? Why not fs.stat?

To be honest, I did not look further than when I found lstat.

use path.join and path.sep instead of slashes in paths to make sure your server works in both windows and unix I will!