Book Image

Build Applications with Meteor

Book Image

Build Applications with Meteor

Overview of this book

This book starts with the basic installation and overview of the main components in Meteor. You’ll get hands-on multiple versatile applications covering a wide range of topics from adding a front-end views with the hottest rendering technology React to implementing a microservices oriented architecture.All the code is written with ES6/7 which is the latest significantly improved JavaScript language. We’ll also look at real-time data streaming, server to server data exchange, responsive styles on the front-end, full-text search functionality, and integration of many third-party libraries and APIs using npm. By the end of the book, you’ll have the skills to quickly prototype and even launch your next app idea in a matter of days.
Table of Contents (16 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
8
Build a Chatbot with Facebook’s Messenger Platform

Setting up the development environment


Installing and running Meteor is extremely easy.

For Linux and iOS, all you need is the terminal and cURL. cURL is basically a command-line tool that we can use to move data with URL syntax, such as a GET, POST, and more, all directly from the terminal.

For Windows users, Meteor comes with an installer. You can download it from https://www.meteor.com/install">https://www.meteor.com/install. All the commands in the book are executed in a Linux terminal; just skip the sudo command and execute the commands as administrator if you are on Windows.

If you don't have cURL installed, open your terminal and install it with the following commands:

  1. Run update as a superuser:
>> sudo apt-get update
  1. Install cURL:
>> sudo apt-get install curl
  1. Verify the installation:
 >> curl --version
  1. Once you have cURL installed, installing Meteor is easy as it's a one line command:
>> curl https://install.meteor.com/ | sh

This will download the latest version of Meteor, and it will install it globally on your machine. Node.js, NPM, MongoDB, and all other default packages will be inside the .meteor directory.

The final installation looks like this:

Meteor 1.4.4.2 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.

In Chapter 9, Build Internet of Things Platform, we will build Node.js apps connecting to a Meteor app. If you don't have Node.js and MongoDB and you want to run them outside Meteor, here's a list of commands and installing scripts that you might find useful:

Install Node.js with cURL

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

sudo apt-get install -y nodejs

Uninstall Node.js

sudo rm /usr/local/bin/{node,npm}

Update node with NPM

sudo npm cache clean -f sudo npm install -g n sudo n stable

Update to specific version with NPM

sudo n 4.4.4

Check the version of Node.js

node -v or node --version

Check the version of NPM

npm -v or npm --version

Install cURL and check its version

sudo apt-get update

sudo apt-get install curl

curl --versionc

Uninstall cURL

sudo apt-get remove --auto-remove curl

Purging cURL config data

sudo apt-get purge --auto-remove curl

MongoDB install(Ubuntu)

sudo apt-get update

sudo apt-get install -y mongodb-org

MongoDB version

mongod --version

Stop MongoDB

sudo service mongod stop

Restart MongoDB

sudo service mongod restart

Remove MongoDB

sudo apt-get purge mongodb-org*

Remove Data Directories

sudo rm -r /var/log/mongodb

sudo rm -r /var/lib/mongodb

The following are the Meteor scripts:

Install Meteor

curl https://install.meteor.com/ | sh

Check the Meteor version

meteor --version

Update Meteor to the latest version

meteor update

Check the Node.js version in Meteor

meteor node -v

Create a Meteor App

meteor create app_name

Add an Atmosphere package to a Meteor app

meteor add package_name

Remove Atmosphere package

meteor remove package_name

List all the Atmosphere packages

meteor list

Install an npm package

meteor npm install package_name --save

List all the npm packages

npm list

Run a Meteor app on a specific port;

the default is 3000

meteor --port 2000

Launch the MongoDB shell in a meteor app

in the app directory execute meteor mongo

Show all databases from the MongoDB shell

show dbs

Switch to a database

use database_name

Show all collections in a database

show collections

Reset Meteor app

meteor reset