- Overview
- Transcript
2.1 Project Overview
In this lesson, I'll introduce the simple contacts application that we'll be working with throughout this course. I'll show you how it fits together and explain what services our Vagrant box will need in order to host a development environment for the app.
1.Introduction3 lessons, 06:03
1.1Introduction01:16
1.2Installing VirtualBox and Vagrant02:05
1.3Advanced Setup: Vagrant and VMware02:42
2.Setting Up Your Node.js Stack6 lessons, 23:57
2.1Project Overview05:05
2.2The Vagrantfile05:02
2.3Installing Node.js Using NVM02:50
2.4Installing MongoDB and Redis05:43
2.5Node.js Development Workflow02:42
2.6Autostart the Node.js Application02:35
3.Exporting and Sharing2 lessons, 09:16
3.1Exporting and Sharing Your Vagrant Box07:28
3.2Sharing Your Local Vagrant Instance01:48
4.Conclusion1 lesson, 00:54
4.1Final Review00:54
2.1 Project Overview
Hi, and welcome back to Easy Node.js Development Environment With Vagrant. Now that we have set up all our prerequisites, we're good to go to use Vagrant for our project dependencies. In this lesson, I will give you an overview of the sample project we're going to use throughout the course. So I have a bit of an app to work with. I created this contacts application using the express framework. It has a form for creating new contacts manually and a Generate Sample Contacts button, which will use socket.io to generate some robot contacts and update the page after it's done to show our new metallic friends. After you have created a contact, you can also edit and delete it. As you can see it's a very basic application. Let's have a look at the codes to show the different parts we are working with. At the top level we have three folders app contains all the luggage, controls, models and views. The config folder is used for setting up the express server. Finally, there is the static folder, which contains the client, JavaScript, and CSS files. There is also the index.js file, and the package.json file. Let us look at this first. It is pretty straightforward having all dependencies for express, like session, shape and method-override. You might also have spotted two dependencies here. Connect-redis and mongoose reach into what we are using, database-wise. But hold on for a minute. We'll get to that. Like I said, we are using socket.io to initiate the background processing. The index.js file contains the meat of the application,setting up all sorts of stuff. First, there is SessionStore, using redis to store user sessions. It really isnt' important in this particular case, since there is no log in, but I thought adding a bit complexity will help pushing the application a bit more into our real world scenario. Then we'll connect Mongos to our database. We're using Mongo DB for storing the context. Next we set the port, which defaults to 4.000, and the templating configuration for jade. I wanted to use flashes. I come from arrays background and I quite like them, therefore I needed to set up the express session. To be able to process form data we need to set up the body parsa, and because we want to structure our application in a style, we need to use method override to simulate put and delete requests in the front end. We then set up our routes, which I'll get to in a second. Our HTTP server, and a circuit configuration. Then we start the server on the set port. Next we look at the contact model. It has a bunch of string properties, and aesthetic methods for generating a number of samples. I'm using Faker to fill the entities with interesting values, and robohash.org for the robotic images. [INAUDIBLE] is also very standard. It features in a parameter which is used to look at a specific contact and index, new, create, edit, update and delete routes. The root route also points to the index. In the controller the end points for these routes are defined. The load method is used when you have an id parameter, when we have methods to handle and all the routes we mentioned before. Finally, let's have a look at the configuration. After the connection we are listening for the generate contacts message from the client. If that gets sent, we're going to generate five sample contacts, and send two messages back. A general notification message, and the contacts, if creating them succeeded. I also added a three second delay, to simulate a heavier workload than we have here. On the client side, we have some j query code to create a Twitter Bootstrap notification, and some code to clone a sample context if that is present, but next time, file and prepend it to the list of contacts. So now that you know what we'll be working with, a quick recap. We're going to need for running our application, longer DB to store our contacts and to store our sessions. In the next lesson we are going to initialize our first Vagrant box and configure to use it with our application. See you there.







