Book Image

MongoDB, Express, Angular, and Node.js Fundamentals

By : Paul Oluyege
Book Image

MongoDB, Express, Angular, and Node.js Fundamentals

By: Paul Oluyege

Overview of this book

MongoDB, Express, Angular and Node.js Fundamentals is a practical guide to the tried-and-true production-ready MEAN stack, with tips and best practices. The book begins by demystifying the MEAN architecture. You’ll take a look at the features of the JavaScript libraries, technologies, and frameworks that make up a MEAN stack. With this book, you'll not only learn how to develop highly scalable, asynchronous, and event-driven APIs quickly with Express and Node.js, but you'll also be able put your full-stack skills to use by building two full-fledged MEAN applications from scratch. You’ll understand how to build a blogging application using the MEAN stack and get to grips with user authentication using MEAN. As you progress through the chapters, you’ll explore some old and new features of Angular, such as pipes, reactive forms, modules and optimizing apps, animations and unit testing, and much more. By the end of the book, you’ll get ready to take control of the MEAN stack and transform into a full-stack JavaScript developer, developing efficient web applications using Javascript technologies.
Table of Contents (9 chapters)
MongoDB, Express, Angular, and Node.js Fundamentals
Preface

Getting Started with Express


Express provides a robust set of features for building web applications. In the first chapter, we briefly talked about Express.js, and discussed its advantages and limitations. This topic is about the implementation of Express in an application.

Creating an Express application requires the following steps:

  1. Importing the Express module

  2. Creating the Express application

  3. Defining the route

  4. Listening to the server

Take a look at the following example in Express:

// load express module
var express = require('express');

//Create express app
var app = express();

// route definition
app.get('/', function (req, res) {
res.send('Hello World');
});

// Start server
app.listen(4000, function () {
    console.log('App listening at Port 4000..');
});

In the preceding code snippet, the Express module is first loaded and assigned to a variable. Then, an app is created using the variable function. The app.get() method is used to define the route by passing in a route path and a callback...