Book Image

Node.js By Example

By : Krasimir Tsonev
Book Image

Node.js By Example

By: Krasimir Tsonev

Overview of this book

If you are a JavaScript developer with no experience with Node.js or server-side web development, this book is for you. It will lead you through creating a fairly complex social network. You will learn how to work with a database and create real-time communication channels.
Table of Contents (13 chapters)
12
Index

Finding friends


The process of finding friends involves a series of changes in our current codebase. The following sections will guide us through the searching and displaying of friend profiles. We will make a couple of improvements in our REST API and define a new controller and model.

Adding the search page

So far, we have pages for registration, login, and profile management. We will add one more link in our navigation—Find friends. In order to do this, we have to update the frontend/tpl/navigation.html file as follows:

<li class="right"><a on-click="goto:logout">Logout</a></li>
<li class="right"><a on-click="goto:profile">Profile</a></li>
<li class="right"><a on-click="goto:find-friends">Find  friends</a></li>

The link that we added at the end will forward the user to a new route. As with the other pages, our router will catch the URL change and fire a handler. Here is a little update of the app.js file:

Router
.add(...