Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building custom server methods


The majority of communications we perform between the client and server in Meteor is done via DDP. There are times, however, where direct server calls can come in very handy. For example, while you're testing, or as an admin, you may create some 'hidden' helper methods to make debugging easier. In other instances, you may want to make very secure or very simple methods available to reduce the vulnerability or complexity of your code. In any case, server methods are a staple of development, and this recipe will walk you through creating and using server-side methods, using the Meteor.methods() function.

Getting ready

To create server methods, we first need a basic application. We'll quickly create a color swatch app. Nothing fancy, but once we're done, we will be able to create server methods with good visual feedback.

Project setup

You will need Meteor installed, and have a project created. In a terminal window, create your root project by entering the following...