Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am trying to write an app with Node.js with Express and Angularjs.
Is it possible that I allow AngularJS to handle all landing requests? and Node.js is purely for APIs? meaning that all routes written in Node.js will be like this:
app.get('/api/users', users.showAll);
app.post('/api/users', users.create);
app.get('/api/users/fb/:fbId', users.findByFb);
app.get('/api/users/:userId', users.show);
app.put('/api/users/:userId', users.update);
app.del('/api/users/:userId', users.del);
And AngularJS will be able to resolve URL by itself e.g. localhost/users/Some-Name?
What are some best practices to follow when integrating the two together?
ALso, is it recommended to have AngularJS and Node.js app to be separated into two different application? and what are some ways to do that?
Thanks in advance!!
Obviously, the design and nuances of any application will dictate how exactly it should be setup, but you can certainly have a single page web application running in Angular making AJAX requests back to your node.js server side API. I have created many small and medium sized apps in exactly this way.
Node.js can handle your API in the way you have designed, but you will need some initial route in node that users will initially hit to bring up the HTML page that bootstraps the angular.js application and loads any additional javascript and css libraries that you will need. You will define that route and then setup the static resources in your node application so that the browser can load these things to spin up the angular app.
The angular application itself will be contained in javascript files that will live in a static resources folder in your express app. Typically, something like /js/myNgApp.js will work to start - but you can get more exotic by separating out controllers, directives, services, etc into their own js files. This is something you can do later on.
Once the angular app is loaded and running in the browser, you will just need to use the $resource service in angular to define your ajax urls to the api in node then have the angular client perform get or post (or whatever) request to these urls.
If security is something you will need in the app, that needs to be implemented as a page and url before loading the angular application. There are security frameworks for express that can help you with this. I use passport.
In Chrome, the developer tools (especially the network tab) will become your best friend.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I've just downloaded - vue-webpack-boilerplate - and the little I've seen of it looks really good :) (first time with webpack + ESlint)
I'm a little confused however - how can I go about adding an express backend to the project?
Not every route is always going to be a vue, sometimes it's an api request or a db call or the like - and if I do hookup an express backend, how can I choose what vue components I want to load?
Am I going about this completely wrong/have misunderstood what this is for?
Thanks
Edit: I've looked at http://vuejs-templates.github.io/webpack/backend.html - but that's not really cleared anything up
You might be confusing with npm build packages like webpack for front-end with back-end express project.
The boilerplate you mention is for front-end. It allow you to develop a static website either with or without SPA and end up with html, css and js files to be deployed at any static file hosting.
There is no wrong to make API call anywhere on client-side. E.g. on every route change, you specify what component to load and it can make an API to call to update the UI. That is SPA for client-side routing. You just have to make a separate express project for the back-end.
You can try Nuxt for server-side rendering (SSR). The main advantage for SSR is SEO friendly but not suitable for dynamic page like profile and checkout page. Nuxt is a universal (client or server routing) Vue app by generating static html during run-time. However it is differ than what you think you want to add express API back-end but you can still populate dynamic data with Async Data
Check this out JAMstack.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Now I program all my web apps with Flask or Django. (blogs, social networks...). I need templates, db access, controllers, routing...
Now I want to do same web applications, but with javascript.
People tell me : You need NodeJs for server-side, Angular for the front, and for example firebase or mongodb. Or also you can use Express JS.
But can I just use Angular JS and Firebase for start a big web app ? Need I Node if Angular can Access/Update/Delete in my db ?
Angular is a client-side framework, so you'll have to at least have some web server to serve your static files. Other than that, if you're using Firebase, you wouldn't technically need any server-side code to handle your logic - but naturally, that depends strongly on what data your application deals with.
If what Firebase provides, doesn't cut it for your cases though, you will need a server-side, and pretty much any web application framework would do. Node.js (using Express), PHP, ASP.NET, whatever your heart desires.
And yes, Angular works perfectly well for creating big complex web applications.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am looking to build a Order Management and Task Management App for my company. I am a beginner in Programming and know only Javascript (Can manage with HTML and CSS ) . This app would also require to connect with a database. Is it possible to build it only using Javascript (without the use of any other languages like PHP etc) and is it advisable. Is there any other more feasible solution.
If Javascript will suffice, a few more queries in the same line
What database would be the best to use ?
Would using Angular JS help ?
How do I search and use if theres a similar project in Github that runs only on Javascript ?
suggest you read more about the MEAN stack, it's a very popular stack that let you build the whole stack (DB, Server side logic, Client Side logic) with Javascript alone.
in short:
MongoDB, a NoSQL database
Express.js, a web application framework that runs on Node.js
Angular.js, a JavaScript MVC framework that runs in browser JavaScript engines
Node.js, an execution environment for event-driven server-side and networking applications
using the angular JS is optional in my opinion, it is required if you want to make it to feel as single page app.
try this on github, an example for MEAN stack.
You have to Choose
Nodejs Server (Javascript)
AngularJS Client (Javascript )
Mysql Backend
They are More Flexible with friendly Solutions
You could build and host your app on something like https://firebase.google.com/ - build the entire thing in eg polymer and let google host it, that way you'd be building the thing entirely in JS, no other language required
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to develop a website using JavaScript/HTML5/CSS3, because it is more flexible in UI. I read internet about AngularJS for the client side and about NODEJS: it can be used to both clent side and server side.
Can anyone kindly inform me about the cons and pros of the following:
use AngularJs for client side and other language for server side (EX : PHP ).
Use NODE.JS for build website
or can I use both?
If you want to check for pros & consof Angular only, here is the list:
PROS
Angular follows MV-Whatever architecture. Hence you can either MVP, MVC or MVVM.
It gives the flexibility to do two way binding. Data binding tries to get rid of writing codes manually by relieving the backend server from creating templates. MVC pipeline is also maintained by the framework itself.
DOM Manipulations at one place: You can make use of angular directives to play with the dom giving a neater code.There are some reusable tags defined by angular folks themselves in directives like ng-class, or ng-show. See Angular Directive Documentation
Test Ready: The fact that AngularJS comes linked with Dependency Injection (DI) makes it ready for unit testing by injecting mock data into controller and measuring the output and behavior.
Ionic Framework: Ionic Framework is written on top of Angular and is mainly used to build hybrid apps. So Angular is useful if you are going to extend your website into a mobile hybrid app.
Cons:
Difficult to adapt the existing code: AngularJS requires the developer to re-implement the entire transformation code which makes it extremely hard to play around while adapting existing code.
Heavy: Their are lighter frameworks like backbone and knockout, however seeing the power of Angular it can be easily negated
Now moving to your question whether Nodejs be used in conjunction to Angularjs my answer to it is:
AWESOME COMBINATION
You can have your server code residing in nodejs and use angularjs at client side keeping the architectures completely different. Since Nodejs also uses javascript there would be less of uptime for developers to learn it and start developing. Infact MEAN (Mongo-Express-Angular-Node) methodology.
Their are various boilerplates available in order to kick start your development. One can be found at MEAN
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
In a single-page application that uses Angular, it seems like most of the things are handled on the client-side. The client seems to just make restful calls to the server.
Following this concept, it seems to me that my server-side will not have any application at all, but only scripts that generate RESTful json data for the client to read.
Perhaps frameworks like Hibernate or those that connects to the database are still relevant since the restful scripts on the server are going to still have to connect to the DB. But what about those MVC frameworks?
Since in a single-page app the server is only required to serve RESTful calls for the client, frameworks such as Spring, Struts (in Java) or Laravel (in PHP), etc, they all are not relevant to SPAs? Which means the server side will probably just need a good RESTful library that we can work with to serve the json data and that's all? Otherwise, what would the views and controllers be on the server in a SPA?
I think that the MVC frameworks are still useful into an SPA application. I am developing a SPA application, and I am using ASP .NET MVC for two things:
To Manage the first page of my application. It allows me to make use of the advantages of this framework such as the facilities for managing joining and minification of scripts.
To return the partial views that I am using in Angular. It allows me to use the razor templating, and also to manage how the partial views are catching.
I think that you can get some advantages if you mix the two things.
I hope that it helps.
if your view and navigation logic its in the client and your server "only" needs to respond to HTTP call (RESTfull probably), what things do you need on the server side:
A way to map urls with server services.
A way to produce a json (or perhaps other formats) output.
Your regular business logic and data-access logic if you need, this its the same that always.
Probably with a good Rest framework like jersey its more than enough, i'm playing a bit with dropwizard (http://dropwizard.codahale.com/) and by the moment i'm really happy with this simple framework.
It is still relevant, however, the view in that case is the mechanisms, producing JSON/XML and it can be implicit.
Spring REST in that case with the underneath controllers is the an example of such. You still need your Application Services will still manipulate on the Model that you will get from some sore of persistency mechanisms, accessed through DAOs.
The architecture is the same, just the data representation in the view is different.