Do I need Express or some other framework in order to make a Node site? - node.js

People keep mentioning Node as a back-end framework but it's actually a runtime. Does this mean I need to install a package like Express in order to actually create a website based on the Node runtime? Does Node come with its' own implementation of a back-end framework?
Looking at the Node docs most of this stuff has nothing to do with usual framework stuff like testing, migrations, MVC, or asset precompilation.

It is not required to use Express or a similar framework to develop web pages since you can just create a web server using Node's http module.
That being said, the additional functionality that a framework like Express would provide is something you should at least consider.

Related

Should I build server-side of application inside nuxt.js server directory?

I want to build full-stack application with Nuxt.js. I am wondering where I should create my server-side inside Nuxt.js or maybe I should create separated project only for server stuff.
I am trying to set up my project but I do not know how I should do it. The application which I am building will have own front-end, back-end and also database (I will use MongoDB) but actually I do not know how I should start. I was reading a lot about SSR and Nuxt.js seems really good if am planing to use Vue.js on fronted. While creating nuxt app I can choose to use Express and then I can see server directory inside my directory structure does it mean that i should build all back-end inside this directory or maybe it is only for small stuff?
I have also another question what if I want to use Nest.js on back-end can i just use npm i -g #nestjs/cli and then nest new project-name inside my server directory ? I was looking also for this answer but almost all results in google for this type are about (comparison between Nuxt.js, Next.js and Nest.js).
It will be my first bigger full-stack project and I want to do it right but I am a really beginner in this so I am looking for answer from more experienced programmers.
You can run express or any node.js server you want inside Nuxt.js. When installing Nuxt.js with scaffolding tool create-nuxt-app, you can choose integrated server-side frameworks : Express, Koa, Hapi, Feathers, Micro, Fastify, Adonis (WIP). There isn't offical Nest.js integration, but you can easily find a starter kit on github.
With create-nuxt-app, if you choose to use any node.js server inside your nuxt app, you will see a server directory inside your directory structure, with the corresponding server-side pre-configured index.js file.
Here is my own feeling about it:
I think the inside solution make sense for a small SPA or Headless project (Ex: parse and serve files, a simple JWT Authentification, a small websocket server...), or for a front-end logic application that cannot fit in client browser and who are nothing to do with the database (like image or file computation).
But generally, this server run the database layer for your Nuxt application: a REST or GraphQL API. It can also run your business logic of your app, serve authentification, and more and more when project growth...
If you think about separation of concerns and microservices
architecture, do not use server inside Nuxt.js. Splitting both frontend and server will result more flexibility. You can host frontend and API in different servers.
So now, do nuxt.js really need a node.js server ?
Yes if you plan to use it in SSR mode, No if you plan to use it like a SPA or Static generated way. Docs here... .
In SSR mode, nuxt.js ask data to your API at the first rendering, and provide a complete SEO compatible page to the client browser or bots. It also provide all javascript that the browser need to navigate and fetch your API. For that, nuxt.js in SSR mode should run with node.js.
I assume you said "back-end" for your API and your business logic application, in this case, you should separate nuxt.js and your server. Two node.js instances to run both.

Lumen (Laravel) V.S NODE.JS Solutions

i need to develop an API backend that it should be :
robust
high performance
provides RESTFULL API
connected to a Mysql storage: i prefer a relation db for the
complexity
only backend not also frontend framework
I'm undecided between :
Lumen : i need only API service because i choose react js as frontend framework.. so i think is better lumen than laravel because i no need frontend
Nodejs api solution: In this moment searching on the web i found Seals and Loopback as framework for my api backend.
I find discortanti opinions ... some told that php solution as Lumen is not good for performance ( see http://www.infoworld.com/article/2866712/php/php-vs-node-js-an-epic-battle-for-developer-mind-share.html ).... and some one told that in this moment there arent reliable api backend framework in node js: seals is not good for performance and about loopback i found few comment... so i ask you what is the best choiche for performance and robust solution ..
I'd recommend Loopback. It has been acquired by IBM so you can expect continued improvement and stability.
If you think about JavaScript for client and server side then you can choose node.js with sails.js framework which is follow full MVC structure. If you use sails.js, you don't need to be expert in node.js. It's easy like other PHP framework like Laravel. For database you can use MongoDB. To work with different types of API include angular.js also. So finally your platform dependencies are:
1. Node.js (Server Side Coding)
2. Sails.js (For Maintain MVC Structure)
3. Angular.js (For Managing Frontend, HTTP request API etc)
4. MongoDB (For Database)
So that you will find out everything require your working development dependency. I think this will help for you.
Thank You :)

Angular2 working with NodeJs

My understanding is that AngularJS including Angular2 is a client-side framework, while Node.JS is a server side platform. They should not cross. But all Angular2 tutorials I found use Node/NPM. Why is that?
Because npm is a package manager for packages written in JavaScript, and JavaScript can run both on client and server side. In other words, frontend and backend applications can both benefit from packages. Many development tools also use node as an underlying process (e.g. Jest-cli).
I would suggest you to use angular2 only on client side. The performance of angular2 really shines when it comes to handling view containers over regular server side codes. On the NodeJS side, I would recommend using es6 features. Which has revolutionised how you can not only code, but also performance.
The reason you see most tutorials using npm is because they are either using TypeScript or a build tool that uses Node to convert to ES5 or build your project.
However you can still build Angular2 apps using the sfx version (self-executing bundle) of Angular2 and using ES5 syntaxes without having to use node or npm. Here is a blog post that shows how to do that
http://blog.thoughtram.io/angular/2015/05/09/writing-angular-2-code-in-es5.html
Angular2 is a front-end framework but a lot of tooling that assists in building Angular2 applications are available via NPM.
If you want a package manager that's geared specifically to front-end development I suggest JSPM. It supports front-end modules of various formats (ie AMD, CommonJS, UMD), handles transpiling out of the box, and can be used as a build tool to concatenate/minify your application code.
You'll still need NPM for many other utilities and you'll need a back-end server for testing (I recommend live-server).
As far as the back-end is concerned. One of the Angular2 dev teams is working on a Node/Express extension that supports isomorphic rendering of JS. In short, it pre-renders the view on the server so the user can interact with it in the browser while the app loads in the background. The start time of launching a fully-featured SPA will still be kind of slow (relatively) but perceived speed will be instantaneous.

Is express similar to grunt? what is the difference? what are the advantages of express over grunt?

I've been working on node,grunt,bower and yeoman from couple of months. I came across MEAN stack applications, in which expressjs is providing the server environment(my understanding). Are both grunt and express similar?
Requesting for some helpful link on express and MEAN stack.
Express is a webserver framework on top of nodejs (like symphony for php).
Grunt is an automation tool (like make or gulp) and not a webserver.
The only thing they have in common is, that they use the JavaScript programming language.
MEAN is a full stack environment for developing web applications. MEAN uses MongoDB as database backend, Express as webserver framework, AngularJs for the client side and all is based on NodeJs. When your application gets more complex and you need some sort of deployment procedure you may use Grunt to automate this.

Angular application requred node.js

I am going to create my first angular application. I have read lots of angular tutorial and many of them mentioned node.js.I am really got confused here.
Do we really need to install node.js and other dependencies to run angular application ?
Can't I just add respective angular libraries in my eclipse and create Angular application?
What are advantages of using node.js?
Also it is necessary to add all angular code is under App folder?
Regards,
Dip
As it is said on note.js website
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
So it depends if you want to have server logic (services) or not. If you are creating just the UI of the app you don't need note.js. Also Angular is NOT dependable on note.js

Resources