Git Product home page Git Product logo

sailsjs-tutorial's Introduction

Introduction

Node.js and IO.js has been sweeping the world of corporate development. Powering names like Paypal, Netflix, Walmart, and IBM, it's clearly a technology that allows for scalability, and offers the advantage of being able to code in one language on the client and server. However, in it's current state there is some question of how to best approach this new technology. The aim of this book is to introduce this technology and make it appraochable.

Sails.js is primarly designed for rapidly building real-time REST Application Programming Interfaces (APIs), and in this book we will explore Sails ability to make APIs as well server side view rendering - for simplicities sake.

Who is this book for?

This book was written to most approachable for those with some experience in JavaScript or server side code in any languages. However it's not meant for experts, unless the desire is specifically to gain experience in the Sails framework. Despite all this, I'll make the best effort to make this book approachable to those with no experience in writing code of any kind.

Prerequisities

As stated in the previous section, I'm working to make this book approachable to any and all individuals, and as such no prerequsites are strictly required. However, that said it's recommended that readers have some experience in JavaScript, whether through Codecademy, or Eloquent JavaScript (highly reccommended even to the seasoned programers), however efforts will be made to make this optional. As well, experience with the command line and access to a Unix based development environment. Rather than embark on the journey of showing Windows users how to setup such an environment I recommend the use of a cloud based development environement like Nitrous.io or Cloud9.

Conventions in this book

Many examples in this book include use of the command line. Examples will use a Unix-style command line prompt, with a dollar sign, as shown below:

$ echo "I'm learning Sails.js"

As discussed in the previous section I recommend that users in Windows environments use a cloud based IDE such as Nitrous.io or Cloud9. Others will hotly argue in favor of command line editors like emacs, vim or vi. While, if you visit a programing shop you are likely to see a range of IDE's like: [Sublime Text (http://www.sublimetext.com/)], [NetBeans (https://netbeans.org/)] (older but it still works) and newer open source IDE's like [Atom (https://atom.io/)] (hosted on [GitHub (https://github.com/atom)]).

This is useful because Sails.js comes with commands that must be run at the command line.

We will use the the forward slash in file paths, the Unix convention for directory separators.

config/env/production.js

Windows Users: Sometimes you will get reverse slashes when copy-and-pasting - make sure to take them out - they usualy will do things that you don't intend on doing.

All file paths should be understood as relative to the application's root. (Here's a [good article (http://www.linuxnix.com/2012/07/abslute-path-vs-relative-path-in-linuxunix.html)] on this - it also has some good Unix commands in there that you would be good to be fimiliar with.)

This book will often include output from various programs. If what you see doesn't match exactly don't worry. You may encounter errors not documented in this book. I encourage you to search for the error message in various places such as Google or Stack Overflow in order to help you solve the problem, which will lend itself greatly to your future development.

This tutorial will cover testing your application. Output from a failed test will be indicated in RED, while output indicated a test passed will be in GREEN.

Code will include syntax highlighting and previously written code will be collapsed as indicated using the elipses below:

module.exports = function() {
  .
  .
  .
  var hello = "Hello World";
  .
  .
  .
}

About the author

Britton Broderick is the author of the Sails.js Tutorial, and Scaling Sails: MVP to SOA His prior experience includes going to school for business at Utah Valley University, realizing almost everything in business could be automated and that we wanted to be the one to do it. Adventures in learning to program followed.

Acknowledgements

The inspiration for this book was Michael Hartl's Ruby on Rails Tutorial. I owe much to him for allowing me to get into web development, and hope this tribute and chance to pay it forward will do justice. Should you ever run into him in your travels buy him a beer.

License

The MIT License

Copyright (c) 2014 Britton Broderick 

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

/*
 * -----------------------------------------------------------------
 * "THE BEERWARE LICENSE" (Revision 43):
 * Britton Broderick wrote this code. As long as you retain this
 * notice you can do whatever you want with this stuff. If we meet
 * some day, and you think this stuff is worth it, you can buy me a
 * beer in return.
 * -----------------------------------------------------------------
 */

sailsjs-tutorial's People

Contributors

britton-jb avatar wallter avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.