Haviv | MEAN Web Development | E-Book | www.sack.de
E-Book

E-Book, Englisch, 354 Seiten

Haviv MEAN Web Development

Master real-time MEAN web application development and learn how to construct a MEAN application using a combination of MongoDB, Express, AngularJS, and Node.js
1. Auflage 2024
ISBN: 978-1-78398-329-2
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)

Master real-time MEAN web application development and learn how to construct a MEAN application using a combination of MongoDB, Express, AngularJS, and Node.js

E-Book, Englisch, 354 Seiten

ISBN: 978-1-78398-329-2
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)



The MEAN stack is a collection of the most popular modern tools for web development; it comprises MongoDB, Express, AngularJS, and Node.js.
Starting with MEAN core frameworks, this project-based guide will explain the key concepts of each framework, how to set them up properly, and how to use popular modules to connect it all together. By following the real-world examples shown in this tutorial, you will scaffold your MEAN application architecture, add an authentication layer, and develop an MVC structure to support your project development. Finally, you will walk through the different tools and frameworks that will help expedite your daily development cycles.
Watch how your application development grows by learning from the only guide that is solely orientated towards building a full, end-to-end, real-time application using the MEAN stack!

Haviv MEAN Web Development jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


Table of Contents - Setting up the environment
- Getting started with the Express framework
- Introduction to MongoDB
- Connecting to MongoDB using the Mongoose module
- Managing users using the Passport module
- Introduction to AngularJS
- Writing cross application MVC Entity/ MCMVW
- Adding real-time functionality using SockJS
- Testing your application
- Tools and Frameworks
- Preface


Installing MongoDB


For MongoDB's stable versions, the official MongoDB website supplies linked binaries that provide the easiest way to install MongoDB on Linux, Mac OS X, and Windows. Notice that you need to download the right architecture version for your operating system. If you use Windows or Linux, make sure to download either the 32-bit or 64-bit version according to your system architecture. Mac users are safe to download the 64-bit version.

Note


The MongoDB versioning scheme works in such a way that only even version numbers mark stable releases, and so versions 2.2.x and 2.4.x are stable, while 2.1.x and 2.3.x are unstable releases and should not be used in production. The latest stable version of MongoDB is 2.6.x.

When you visit the download page at http://mongodb.org/downloads, you'll be offered a download of an archive containing the binaries you need to install MongoDB. After downloading and extracting the archive file, you will need to locate the binary, which is usually located in the folder. The process runs the main MongoDB server process, which can be used as a standalone server or a single node of a MongoDB replica set. In our case, we will use MongoDB as a standalone server. The process requires a folder to store the database files in (the default folder is ) and a port to listen to (the default port is ). In the following subsections, we'll go over the setup steps for each operating system; we'll begin with the common Windows installation process.

Note


It is recommended that you learn more about MongoDB by visiting the official documentation at https://mongodb.org.

Installing MongoDB on Windows


Once you have downloaded the right version, unpack the archive file, and move the folder to . MongoDB uses a default folder to store its files. On Windows, the default location is , so in the command prompt, go to and issue the following command:

> md data\db

Tip


You can tell the service to use an alternative path for the data files using the command-line flag.

Once you've moved the MongoDB files to the right folder and finished creating the data folders, you'll get two options while running the main MongoDB service.

Running MongoDB manually


To run MongoDB manually, you will need to run the binary. So, open the command prompt and issue the following command:

> C:\mongodb\bin\mongod.exe

The preceding command will run the main MongoDB service that starts listening to the default port. If everything goes well, you should see a console output similar to the following screenshot.

Running the MongoDB server on Windows

Depending on the Windows security level, a security alert dialog, which notifies you about the blocking of some service features, will be issued. If this occurs, select a private network and click on Allow Access.

Note


You should be aware that the MongoDB service is self-contained, so you can alternatively run it from any folder of your choice.

Running MongoDB as a Windows Service


The more popular approach is running MongoDB automatically after every reboot cycle. Before you begin setting up MongoDB as a Windows Service, it's considered good practice to specify a path for the MongoDB log and configuration files. Start by creating a folder for these files by running the following command in your command prompt:

> md C:\mongodb\log

Then, you'll be able to create a configuration file using the command-line flag, so in the command prompt, issue the following command:

> echo logpath=C:\mongodb\log\mongo.log > C:\mongodb\mongod.cfg

When you have your configuration file in place, open a new command prompt window with administrative privileges by right-clicking on the command prompt icon and clicking on Run as administrator. In the new command prompt window, install the MongoDB service by running the following command:

> sc.exe create MongoDB binPath= "\"C:\mongodb\bin\mongod.exe\" --service --config=\"C:\mongodb\mongod.cfg\"" DisplayName= "MongoDB 2.6" start= "auto"

If the service was successfully created, you will get the following log message:

[SC] CreateService SUCCESS

Notice that the install process will only succeed if your configuration file is set correctly and contains the option. After installing your MongoDB service, you can run it by executing the following command in the administrative command prompt window:

> net start MongoDB

Tip


Downloading the example code

You can download the example code files for all the Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed to you.

Be aware that the MongoDB configuration file can be modified to accommodate your needs. You can learn more about it by visiting http://docs.mongodb.org/manual/reference/configuration-options/.

Installing MongoDB on Mac OS X and Linux


In this section, you'll learn the different ways of installing MongoDB on Unix-based operating systems. Let's begin with the simplest way to install MongoDB, which involves downloading MongoDB's precompiled binaries.

Installing MongoDB from binaries


You can download the right version of MongoDB using the download page at http://www.mongodb.org/downloads. Alternatively, you can do this via by executing the following command:

$ curl -O http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.4.tgz

Notice that we have downloaded the Mac OS X 64-bit version, so make sure you alter the command to fit the version suitable for your machine. After the downloading process is over, unpack the file by issuing the following command in your command-line tool:

$ tar -zxvf mongodb-osx-x86_64-2.6.4.tgz

Now, change the name of the extracted folder to a simpler folder name by running the following command:

$ mv mongodb-osx-x86_64-2.6.4 mongodb

MongoDB uses a default folder to store its files. On Linux and Mac OS X, the default location is , so in your command-line tool run the following command:

$ mkdir -p /data/db

Note


You may experience some troubles creating this folder. This is usually a permission issue, so use or super user when running the preceding command.

The preceding command will create the and folders because the flag creates parent folders as well. Notice that the default folder is located outside of your folder, so do make sure you set the folder permission by running the following command:

$ chown -R $USER /data/db

Now that you have everything prepared, use your command-line tool and go to the folder to run the service as follows:

$ cd mongodb/bin $ mongod

This will run the main MongoDB service, which will start listening to the default port. If everything goes well, you should see a console output similar to the following screenshot:

Running the MongoDB server on Mac OS X

Install MongoDB using a package manager


Sometimes the easiest way to install MongoDB is by using a package manager. The downside is that some package managers are falling behind in supporting the latest version. Luckily, the team behind MongoDB also maintains the official packages for RedHat, Debian, and Ubuntu, as well as a Hombrew package for Mac OS X. Note that you'll have to configure your package manager repository to include the MongoDB servers to download the official packages.

To install MongoDB on Red Hat Enterprise, CentOS, or Fedora using Yum, follow the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/.

To install MongoDB on Ubuntu using APT, follow the instructions at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/.

To install MongoDB on Debian using APT, follow the instructions at...


Haviv Amos Q. :

Amos Q. Haviv is a software developer, technical consultant, and the creator of MEAN.IO and MEAN.JS. He has been a full-stack developer for almost a decade and worked for multiple start-ups and enterprise companies. For the past 6 years, Amos has been working with full-stack JavaScript solutions, including Node.js and MongoDB, as well as frontend frameworks such as Angular and React. In 2013, he created the first popular boilerplate for MEAN applications, MEAN.IO, and currently continues the development of MEAN solutions at http://meanjs.org. He also gives lectures on advanced web technologies at meetups and conferences, and he guides development teams at various companies.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.