As announced some days ago in this tutorial we will see how to build a chat application using AngularJS as frontend and Loopback for backend. A demo can be found here. The communications from AngularJS to the backend will be made via REST API, meanwhile the real time messaging will be handled with Socket.io. The chat will be available only for registered users so we need to setup the authentication process in both AngularJS and in Loopback. A user, once logged in, can join an already created room or can create new rooms as he like.
Loopback is one of the most promising Node Js framework based on Express and maintained from Strongloop a nice startup based in San Mateo and recently acquired by IBM. Strongloop and Loopback are enterprise grade framework for web and mobile application developed on NodeJS and based on Express. In this tutorial we will use Loopback to create a simple API backend to serve a Todo application. We will not use the visual tool, arc, provided by Strongloop but instead we will use simple command line tool to model all the needed component for the application.
Think about an app where you want to notify events to the users… probably you want to make it in realtime…
Web socket and Socket.IO in particular make it possible. But Laravel from it side doesn’t have direct support for http socket, so we have to implement a little NodeJS Socket.IO server and make possible to push message to it from the Laravel backend.
In the first part of this tutorial we have installed all the necessary module to make a good authentication workflow with AngularJS and also created the view for that purpose. In this second part we will see how to create the REST API on the Express application to serve the authentication application.
Like any other web application your MEAN project need an authentication system to protect sections. User must register to visit some page or use some feature. For the Express framework the best solution you can take is to use a module called PassportJS. Passport can be use to authenticate users with more then 140 strategies like local storage, facebook, google or twitter.