Skip to main content

Posts

Showing posts from March, 2017

Setting Up Our Node Application server.js

Since this is our starter kit for a single page MEAN application, we are going to keep this simple. The entire code for the file is here and it is commented for help understanding. // server.js // modules ================================================= var express = require ( 'express' ) ; var app = express ( ) ; var bodyParser = require ( 'body-parser' ) ; var methodOverride = require ( 'method-override' ) ; // configuration =========================================== // config files var db = require ( './config/db' ) ; // set our port var port = process . env . PORT || 8080 ; // connect to our mongoDB database // (uncomment after you enter in your own credentials in config/db.js) // mongoose.connect(db.url); // get all data/stuff of the body (POST) parameters // parse application/json app . use ( bodyParser . json ( ) ) ; // parse application/vnd.api+json as json app . use ( bodyPar

Starting Our Node Application package.json

All Node applications will start with a  package.json  file so let’s begin with that. { "name" : "starter-node-angular" , "main" : "server.js" , "dependencies" : { "express" : "~4.5.1" , "mongoose" : "~3.8.0" , "body-parser" : "~1.4.2" , "method-override" : "~2.0.2" } } That’s it! Now our application will know that we want to use Express and Mongoose. INSTALL NODE MODULES To install the dependencies we just setup, just go into your console and type: npm install  You’ll see your application working to bring in those modules into the  node_modules  directory that it creates. Now that we have those, let’s set up our application in  server.js

MEAN Stack SPA - What We’ll Be Building

What We’ll Be Building A lot of the applications we’ve dealt with so far had a specific function, like our Node and Angular To-Do Single Page Application. We are going to step away from that and just a good old getting started application. This will be very barebones but hopefully it will help you set up your applications. Let’s just call it a  starter kit . APPLICATION REQUIREMENTS Single Page Application Node.js backend with Express and MongoDB AngularJS frontend Modular Angular components (controllers, services) Good application structure so our app can grow The Backend Node, MongoDB, Express Three letters out of the MEAN stack will be handled on the backend, our server. We will  create our server ,  configure our application , and  handle application routing . TOOLS REQUIRED We will need Node and to make our lives easier, we’ll use  bower  to pull in all our dependencies. Application Structure By the end of this tutorial, we will have a basic application

Become a MEAN Stack Developer

The MEAN stack is  MongoDB ,  Express.js ,  AngularJS  (or  Angular ), and  Node.js . Because all components of the MEAN stack support programs written in JavaScript, MEAN applications can be written in one language for both  server-side  and  client-side  execution environments. MEAN  was coined by Valeri Karpov, a MongoDB developer. He introduced the term in a blog post. The logo concept, initially created by Austin Anderson for the original MEAN stack  LinkedIn  group, is an assembly of the first letter of each component of the MEAN acronym. The components of the MEAN stack are as follows: M ongoDB, a NoSQL database E xpress.js, a web application framework that runs on Node.js A ngular.js or  A ngular, JavaScript MVC frameworks that run in browser JavaScript engines N ode.js, an execution environment for event-driven server-side and networking applications