Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sails

Package Overview
Dependencies
Maintainers
1
Versions
236
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails - npm Package Compare versions

Comparing version 0.7.0-2 to 0.7.0-3

2

package.json

@@ -18,3 +18,3 @@ {

],
"version": "0.7.0-2",
"version": "0.7.0-3",
"description": "Realtime MVC framework for Node.JS with support for Socket.io (built on Express)",

@@ -21,0 +21,0 @@ "homepage": "http://sailsjs.com",

@@ -1,2 +0,2 @@

![sails.jpg](http://i.imgur.com/o0Qsp.jpg)
![image_devInTub@2x.png](http://i.imgur.com/Tj9Nk.png)

@@ -6,3 +6,151 @@ # Sails

## Features
# Installation
To install the latest stable release with the command-line tool:
```sh
sudo npm -g install sails
```
# Creating a New Sails Project
Create a new app
```sh
# Create the app
sails new testProject
```
Lift Sails
```sh
# cd into the new folder
cd testProject
# Fire up the server
sails lift
```
The default port for Sails is 1337. At this point if you visit <a href="http://localhost:1337/">http://localhost:1337/</a> You will see
the default index.html page. Now, let's get Sails to tell us Hello.
# Hello, Sails!
To get Sails to say "Hello World!", you need only to define one controller with an action and define
one route. Lets start with the controller.
```sh
sails generate controller hello index
```
This will generate a file called `HelloController.js` in your app's `api/controllers` directory with one action, `index()`.
Now let's edit that action to send back the string `'Hello World!'`.
```javascript
var HelloController = {
index: function(req, res) {
res.send('Hello World!');
}
}
exports = HelloController;
```
After you have added that, you will want to remove the default index.html page that shows at the
start of your application.
```sh
rm ui/public/index.html
```
We want the application to display this hello response when a request for the root "/" route
comes in. Go into the **/config/routes.js** file. Here you can manually define these mappings,
and here we will do so. Change the file to look like this.
```javascript
var routes = {
'/': {
controller: 'hello',
action: 'index'
}
}
module.exports = routes;
```
As you will see when working more with Sails, one great feature is that by default, you do not have
to define incoming routes to controller actions. This is talked more about in the
<a href="https://github.com/balderdashy/sails/wiki/Routing">Routing page</a> of this wiki.
Finally, restart the server by going to your node terminal and pressing control+c. Then enter the
following.
```sh
sails lift
```
Now when you visit <a href="http://localhost:1337/">http://localhost:1337/</a> your browser should say **'Hello World!'**.
# Creating a Model
Creating a model is very easy with the command line tool. You can even define attributes and their
type by adding arguments at the end of the command. To generate a User model, enter the following:
```
sails generate model User
```
You will see that this creates a user model at **/api/model/User.js**. Let's give her a name-- try uncommenting the name attribute so it looks more or less like this:
```javascript
var User = {
attributes : {
name: 'STRING'
}
};
module.exports = User;
```
# What's Better Than Scaffolding? How About a free JSON API?
Sails API scaffolding is nothing like Rails scaffolding. HTML scaffolds just don't make sense for
modern web apps! Instead, Sails automatically builds a RESTful JSON API for your models. Best of
all, it supports HTTP _and_ WebSockets! By default for every controller you create, you get the
basic CRUD operations created automatically.
For instance, after generating the User model above, if you visit `http://localhost:1337/user/create`, you'll see:
```json
{
"createdAt": "2013-01-10T01:33:19.105Z",
"updatedAt": "2013-01-10T01:33:19.105Z",
"id": 1
}
```
That's it! You just created a model in the database! You can also `find`, `update`, and `destroy` users:
```
# List of all users
http://localhost:1337/user
# Find the user with id 1
http://localhost:1337/user/1
# Create a new user
http://localhost:1337/user/create?name=Fisslewick
(or send an HTTP POST to http://localhost:1337/user)
# Update the name of the user with id 1
http://localhost:1337/user/update/1?name=Gordo
(or send an HTTP PUT to http://localhost:1337/user/1)
# Destroy the user with id 1
http://localhost:1337/user/destroy/1
(or send an HTTP DELETE to http://localhost:1337/user/1)
```
## Additional Features
Sails does a few things other Node.js MVC frameworks can't do:

@@ -19,34 +167,24 @@ - Automatically generated JSON API for manipulating models means you don't have to write any backend code to build simple database apps

To learn more, check out the documentation here:
https://github.com/balderdashy/sails/wiki/_pages
Installation
Dependencies and Compatibility
--
To install the latest stable release:
```
npm install sails
```
Tested with node 0.8.1
Sails is built on the rock-solid foundations of ExpressJS and Socket.io.
Or to install with the command line tool: ```sudo npm install -g sails```
> NOTE: Sails is currently in open beta-- but lots of folks (including us) are using it in production today.
> If you're planning on using Sails in a production environment, make sure you lock down your dependency in your project's package.json file.
> (The next version of the Sails command-line tool does this for you, but it's not released yet.)
> We're on the cusp of a major release which will introduce support for a new ORM, Waterline.
Getting Started
--
If you installed Sails with the command line tool above, the following command will generate a new Sails project, ```nameOfNewApp/```, in the current directory:
```sails nameOfNewApp```
Then run the app:
```
cd nameOfNewApp
node app.js
```
Example
![icon_circlechart@2x.png](http://i.imgur.com/hXc06.png)
Demo
--
#### Live demo
*Try it in two browser windows*

@@ -56,20 +194,17 @@

<!--
#### Code
https://github.com/balderdashy/sails-example
-->
### Philosophy
Like other MVC frameworks, Sails espouses a same convention-over-configuration philosophy and emphasis on developer happiness, but takes it a step further. Like Node.js, using Sails means your app is written entirely in JavaScript, the language you or your team is already using to build the frontend portion of your web or mobile web app. This cuts development to a fraction of the time.
We've used Sails to build production-ready, realtime apps in a matter of weeks. In the past, that would have taken us months!
### Performance
Since Sails is written in Node.js, your servers reap the performance benefits of an event-driven, asynchronous architecture. (http://venturebeat.com/2011/08/16/linkedin-node/)
Dependencies and Compatibility
--
Tested with node 0.8.1
Sails is built on the rock-solid foundations of ExpressJS and Socket.io.
![icon_circleheart@2x.png](http://i.imgur.com/liHPV.png)
## Who Built This?

@@ -82,2 +217,9 @@

![icon_circlelightbulb@2x.png](http://i.imgur.com/eOFXn.png)
License

@@ -88,2 +230,3 @@ --

The MIT License (MIT)

@@ -90,0 +233,0 @@ --

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc