In this lesson we will initialize our Express application using
After loading express through npm we will look at a couple basic functions Express exposes to us such as
.send. This will allow basic interaction via the url.
We will also see how using a package like
nodemon can allow for rapid iteration when developing an application.
I think, "res" (the second argument of callback function) is "response", not "result".
The cliche is worth repeating. Coding standards exist for the purpose of working with others. If we all worked alone, we wouldn't need stye guides.
One reason for the popularity of Express is how truly readable the source is. Similarly, a reason for the popularity of Node is that the community bought strongly in to a common coding style, which has led to higher readability of npm modules. I think that by not following suit, this series is weaker. https://github.com/felixge/node-style-guide
That said, the content is still excellent!
You're absolutely right. I misspoke and it slipped through in the edit process, sorry about that. Thankfully, there was only one instance where I did that and I say response everywhere else in the series.
Hi Nick, thanks and I'm glad you enjoyed the series.
I'm also sorry you find the lack of semicolons distracting. I personally go back and forth on the issue, but don't feel strongly either way. I've recently been omitting them, partially because I switched to Atom and the standard-linter and standard-fixer packages were the best combo I found for painlessly keeping files formatted.
I think the point that resonates with me the most on the issue is that the rules for when you NEED semicolons is much simpler than when you don't. The only time they are 100% required is when starting a line with ( or [, which is extremely rare. (With the possible exception of IIFEs.)
While using semicolons is certainly more popular than not using them, I don't think I'd consider it non-idiomatic. It's just a stylistic choice, though I did get a good laugh when the repo you linked to referred to a HN thread as scientific proof. :) I think http://standardjs.com/rules.html#automatic-semicolon-insertion-asi- makes some good points, and the video linked there expands a bit on how the rules get a bit murkier when using semicolons.
All of that said, I do appreciate your feedback. I debated on whether or not to use that style for the videos, and if I get more feedback that it's distracting I may change course in the future.
Thanks for watching, Ben
Ben, Ok, I get it. You write code for yourself :--)
Bugs that would be avoided with the use of the semi-colon are some of the nastiest to find. I've got a co-worker who only recently agreed to use semi-colons when the team wasted 4 hours tracking down a bug of his that would have been avoided with a semi-colon. Being an old guy (ouch), I've seen this movie before. Experiments with the unconventional ends as the pain of unnecessary bugs always trumps stylistic preference.
"Always use semicolons. Relying on implicit insertion can cause subtle, hard to debug problems. Don't do it. You're better than that."
The Google guide also describes the dangers of not using semi-colons.
jQuery Style Guide https://contribute.jquery.org/style-guide/js/ "Semicolons Use them. Never rely on ASI."
Finally, the collaboration from 20+ leading JS practitioners that endeavors to define "idiomatic": 5) idiomatic.js https://github.com/rwaldron/idiomatic.js "We do not intend to impose my style preferences on other people's code or projects; if an existing common style exists, it should be respected."
"Arguments over style are pointless. There should be a style guide, and you should follow it" Rebecca Murphey "Part of being a good steward to a successful project is realizing that writing code for yourself is a Bad Idea™. If thousands of people are using your code, then write your code for maximum clarity, not your personal preference of how to get clever within the spec." Idan Gazit
Sir, aren't we supposed to pronounce nodemon like we pronounce pokemon ;)? Thanks for the lesson.
I got an error message in my terminal when I type in node index.js
module.js:442 throw err; ^
Thank for the lesson. I am a nebbie, what does '-y' means in npm init -y ?
npm init by itself will ask you a series of questions to determine how to populate the package.json file it creates.
-y, as well as
npm to use the values defined in your
~/.npmrc file and skip the questions.
what is the atom theme you are using in the video?
I think that was a slightly modified version of Tomorrow Night Eighties. These days I'm using Oceanic Next, which is similar.
How come we need to use 'run' when start nodemon but not when using 'npm start'?
Hey Brad, support for some scripts, like start and test, is built into npm. https://docs.npmjs.com/misc/scripts
To run custom scripts you have to pretend run to the name. https://docs.npmjs.com/cli/run-script
Hi Ben, How to change PORT in express generator that it has already gived default to 3000 ? Im Stuck.., please Help