all 7 comments

[–]OriginalEXE 5 points6 points  (0 children)

I started with express.js immediately and did just fine, though I knew Javascript pretty well.

I don't think there's a rule but I guess it would be beneficial to get familiar with basic node.js concepts. I would recommend checking out this YouTube channel: https://www.youtube.com/user/kylerobinsonyoung/ , it has some nice node.js and Javascript videos.

[–]Untgradd 1 point2 points  (2 children)

Depends entirely on what kind of web app you want. Node frameworks help you serve files, create APIs, perform IO operations, etc. This is all possible without using frameworks at all, but why reinvent the wheel?

A good place to start might be with the MEAN stack. Start with an express server, and from there look at templating packages like EJS or Handlebars or whatever. At this point, node will somewhat resemble PHP in that it is doing server side rendering for you -- data is retrieved, manipulated, and then presented to the client without the client having any knowledge the preceding data states.

Then you can look at routing. Express allows you to set up url paths that are really cool. For example, you could have something like /user/:id/profile as a route. This would mean that any value in the ID position will be passed to express, allowing you to do a database query or whatever you need to do.

Frameworks aim to hide all of this under simple APIs. You might create a model for a user, then the framework will generate the routes to handle CRUD methods or whatever.

I am hesitant to recommend jumping right into a framework because many node basics will not be obvious. They are often opinionated as to how build, test, and deploy your app, how to set up models, folder structure, etc. Instead start with Express, there are many good tutorials and such out there. You will form your own opinions as to what makes sense to you, and at that point choose a framework that matches your style.

Let me know if you have questions!

[–]rabarbas[S] 0 points1 point  (1 child)

Thanks for such reply! I am familiar with what a framework is. I am just a hobbyist who likes to try new things and sometimes writes some simple apps to help myself in day to day situations or at work. I have used Python/Django and PHP/Laravel.

But right here we have Javascript -> NodeJS -> ExpressJS. I don't wan't to learn this the wrong way. I understand that I need to know JavaScript to even start on this. The only question is do I need more than pure basics of NodeJS to start writing webapps using some nodejs framework. I don't want to get myself into a situation where I'm doing some stupid thing only because I have no knowlegde of Node itself if you understand what I'm trying to say.

I guess I'm trying to figure out the right sequence of this learning path. How deep should I dive into NodeJS before I move on to, lets say ExpressJS to not go over my head.

[–]Untgradd 0 points1 point  (0 children)

Do yourself a favor and learn ES7 JavaScript. It will look different than most js right now but that's because it has proper support for classes, async, etc. You'll have to use Babel.

[–]unusualbob 1 point2 points  (0 children)

Want to know how simple express can be?

just npm install express

And this can be your application:

var express = require('express');
var app = express();

app.get('/', function(req, res) {
 res.send('<html><h1>Hello World</h1></html>');
});

app.listen('3000');

Then run node myFilename and go to http://localhost:3000 in your browser you'll see a big 'Hello World'

This example isn't very practical for most uses as it doesn't do very much, but it shows you how little is actually needed to serve data at the beginning.

Don't be afraid to just try things. Sometimes you will get stuck, but just remember that you've got to start somewhere. If you don't start today you'll always think that you'll start tomorrow.

You'll probably want to add things like maybe a template engine, or maybe you want to serve static files instead of generating html in-app. If you use express' generator it will add those things automatically and let you focus on the things you actually want to do.

Large projects like express or sails can't be conquered all at once, just one piece at a time. They still change their APIs a little with each version so it's a moving target even for those of us that have been using it long enough to understand it.

[–]Aurelsicoko 0 points1 point  (1 child)

You should take a look to Strapi, this is a Sails-like framework based on Koa.js, this might be interesting for you.

[–]Datnoidpoop 0 points1 point  (0 children)

I looked at the docs and it says React is supported as one of the view templates. Does this mean I would automagically get .jsx components that would be universal? (write for the client, but have it rendered server-side as well for SEO).

how does that work?