INTRODUCTION TO METEOR

Pavel Kurnosov


What is Meteor?


Meteor is an ultra-simple environment for building modern websites. What once took weeks, even with the best tools, now takes hours with Meteor.



Install meteor


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



Seven Principles of Meteor



Data on the Wire


Don't send HTML over the network. Send data and let the client decide how to render it.


One Language


Write both the client and the server parts of your interface in JavaScript.


Database Everywhere


Use the same transparent API to access your database from the client or the server.


Full Stack Reactivity


Make realtime the default. All layers, from database to template, should make an event-driven interface available.


Embrace the Ecosystem


Meteor is open source and integrates, rather than replaces, existing open source tools and frameworks.


Simplicity Equals Productivity


The best way to make something seem simple is to have it actually be simple. Accomplish this through clean, classically beautiful APIs.

Inside Meteor


Meteor tool


build tool analogous to make, rake.
It gathers up all of the source files and assets in your application, carries out any necessary build steps, fetches the packages used by your app, and outputs a standalone, ready-to-run application bundle



Meteorite

tool that will help you download and manage your Atmosphere packages



Demo


Create and run first project using mrt

Everything package

Meteor is a library of packages: pre-written, self-contained modules that you might need in your app

Plans for 1.0 "Andromeda" release



DEMo


list of default packages and community packages


Application structure


Meteor automates the packaging and transmission of different components. And, it is quite flexible about how you choose to structure those components in your file tree

Few rules to remember :)


1. main.* files are loaded last at each folder level.
2. Files in app/client are only loaded on the client
3. app/client/compatibility is a place to place JavaScript libraries and are executed prior to other client-side JavaScript files
4. Files in app/server are only loaded on the server
5. Files in the app/private directory are for static server assets.
6. Files in the app/lib directory are loaded first
7. Files in subdirectories are loaded before files in parent directories
8. Files are loaded alphabetically by filename in each directory
9. app/public is the place to store assets like favicon.ico or robots.txt


Security


By default, a new Meteor app includes the autopublish and insecure packages


Publish and Subscribe


These functions control how Meteor servers publish sets of records and how clients can subscribe to those sets.


Publish


Meteor.publish("rooms", function () { return Rooms.find({}, { fields: { secretInfo: 0 } }); });


Subscribe



                Meteor.subscribe("rooms");
                Rooms = new Meteor.Collection("rooms");
            

Methods


Methods are remote functions that Meteor clients can invoke.


                //server side
                Meteor.methods({
                    foo: function (arg1, arg2) {
                        check(arg1, String);
                        check(arg2, [Number]);
                        // .. do stuff ..
                        if (you want to throw an error)
                            throw new Meteor.Error(404, "Can't find my pants");
                        return "some return value";
                    }
                });

                //client side
                Meteor.call('foo', 1, 2, function (error, result) { ... } );
            



Restrict client side code access to DB



                Parties.allow({
                    insert: function (userId, party) {
                        return false;
                    }
                });
            



Accounts and Authentication


It features secure password login using the Secure Remote Password protocol, and integration with external services
Accounts-ui package worth to mention it.


Input validation


Meteor provides a lightweight library for checking that arguments and other values are the type you expect them to be.


                check(username, String)
            


DDP protocol


Connection using websockets and it give some security benefits like - no cookies



Deployment

Running on Meteor's infrastructure


                $ meteor deploy myapp.meteor.com
            


Running on your own infrastructure


                $ meteor bundle myapp.tgz
            




Demo


Questions?


Introduction to Meteor

By Pavel Kurnosov

Introduction to Meteor

  • 3,044