Es un framework MVC creado por Mike McNeil en 2012.
// Bird.js
module.exports = {
attributes: {
name: {
type: 'string'
},
wingspan: {
type: 'float',
required: true
},
wingspanUnits: {
type: 'string',
enum: ['cm', 'in', 'm', 'mm'],
defaultsTo: 'cm'
}
}
}
<%= user.name %>'s first view
My corndog collection:
<% _.each(corndogs, function (corndog) { %>
- <%= corndog.name %>
<% }) %>
// config/routes.js
module.exports.routes = {
'get /signup': { view: 'conversion/signup' },
'post /signup': 'AuthController.processSignup',
'get /login': { view: 'portal/login' },
'post /login': 'AuthController.processLogin',
'/logout': 'AuthController.logout',
'get /me': 'UserController.profile'
}
socket = io.connect();
typeof console !== 'undefined' &&
console.log('Connecting Socket.io to Sails.js...');
socket.on('connect', function socketConnected() {
typeof console !== 'undefined' &&
console.log(
'Socket is now connected and globally accessible as `socket`.\n' +
'e.g. to send a GET request to Sails via Socket.io, try: \n' +
'`socket.get("/foo", function (response) { console.log(response); })`'
);
socket.on('message', function newMessageFromSails ( message ) {
typeof console !== 'undefined' &&
console.log('New message received from Sails ::\n', message);
});
});