As always, there's obviously plenty of resources 'out there' - how else did I learn what I learned, right? These next few posts are meant to point the great whomever in a better direction. The biggest problem w/ learning these new tools for me has been whiling away the hours just trying to answer the simplest of questions. For example, "what the f*() is Express used for?" Or, "Holy sh*(), what do you mean, I have to download a database?"
By the way, all of my examples assume Ubuntu 16.04 LTS.
Ignorance allowed. MongoDB is not terribly difficult to set up. Everywhere I've been says to do the same thing - just ask the MongoDB people how to set up your sh*().
Go Here
One more thing, download the Mongoose library. It makes things easier to 'interact' with MongoDB. Go figure.
Mongoose.
From what I gather, Express is primarily used to route endpoints. It allows for communication between a database, in this case, Mongo.
Of course, they explain themselves best here, Express.
By the way, use Express 4.x if you can. There's a lot different between it and Express 3.x. By and large, the difference is that the newer version has very few libraries pre-loaded whereas 3.x has, like, everything built in.
Here's more on all those differences.
You can get your boiler-plate on (I hate that term) by using the 'express-generator'. As with all things, you must also download this b*)*)h. Find out all the details here.
For brevity's sake, the global command is: $ npm install express-generator -g
Don't give me that best practices horsehit, either.
You must, of course, download/setup all the tools.
$ nodeenv <name of your env>
$ sudo service mongod start/stop
Node.js v7.2.0
.
$ npm start` and listen on port 3000
app.js
file included in the main directory - this is assuming you've used express-generator, of course.
Oh, by the way, if your dependencies aren't working, and you're like, "what the hell?", try the following:
$ npm install
to install whatever is located in your package.json
. If you didn't know (I didn't), that's what sets up your entire environment and allows others to work w/ the same versions, libraries, etc. you've used.
$ npm start
.
When it comes down to it, the act of doing tutorials (while sucking) really seems to be the best way to learn this stuff. I was pointed in the direction of Thinkster - they have several, practical tutorials for learning poplular frameworks.
This dude also helped me tons. He's got some seriously good example code. Also, he actually de-mystifies how to fu09c*()ing DELETE
things using Mongoose.
Kendrick Coleman
Published: 2017-03-28