Sails

Node.js的实时MVC框架。(Realtime MVC Framework for Node.js. )

Github stars Tracking Chart

Sails.js是一个Web框架,可以轻松构建定制的企业级Node.js应用程序。 它的设计类似于Ruby on Rails框架的MVC架构,但支持更加现代化的面向数据的Web应用和API开发风格。 它特别适合建立实时的功能,如聊天。

Sails.js 是一种轻量的框架,它建立于 Express 之上。它的小模块集合在一起,为 Node.js 应用提供了简单性、可维护性和结构约定。

Sails.js 特性:

  • 100%JavaScript。
像其他MVC框架一样,Sails构建的重点是开发人员的快乐和一个约定配置理念。但是Node.js把这个原理提升到了一个新的水平。建立在Sails之上意味着您的应用程序完全以JavaScript编写,您和您的团队已经在浏览器中已经使用的语言。由于您在上下文转换方面花费的时间越少,您就可以以更一致的风格编写代码,这使得开发更有成效和有趣。
  • 任何数据库。
Sails捆绑了强大的ORM,Waterline,它提供了一个简单的数据访问层,无论您使用什么数据库,它都可以正常工作。除了大量的社区项目之外,MySQL,MongoDB,PostgreSQL,Redis和本地磁盘都有正式支持的适配器。
  • 强大的关联特性。
Sails为熟悉的关系模型提供了新的功能,旨在使数据建模更加实用。您可以执行所有与之相同的操作(一对多,多对多),但也可以为每个模型分配多个命名关联(例如,一个蛋糕可能有两个人的集合: “猎人”和“食者”)。更好的是,您可以将不同的模型分配给不同的数据库,并且您的关联/连接仍然可以工作 —— 即使在NoSQL和关系边界。 Sails隐含地/自动连接(JOIN)MySQL表与Mongo集合没有问题,反之亦然。
  • 自动生成REST API。
Sails带有蓝图,有助于启动应用程序的后端,而无需编写任何代码。只需运行Sails就可以生成 api dentist,你会得到一个API,可以让您搜索,分页,排序,过滤,创建,销毁,更新和关联 dentists。由于这些蓝图操作基于与Sails相同的底层技术,因此它们还可以与Websockets和任何支持的数据库开箱即用。
  • 支持WebSockets,无需其他代码。
在过去,添加实时/“彗星”功能意味着维护两个独立的代码库。但是,由于Sails中的请求解释器会为您传送套接字消息,所以它们将自动与Sails应用程序中的每个路由以及任何现有的Express路由/中间件兼容。参数,会话和流媒体接口的归一化都被照顾。换句话说,您编写的代码可以与WebSockets和HTTP一起工作,而无需任何额外的工作。
  • 声明性,可重复使用的安全策略。
Sails默认以策略的形式提供基本的安全性和基于角色的访问控制 - 在控制器和操作之前运行的简单,可重用的中间件功能。写作策略鼓励封装,大大简化了您的业务逻辑,并减少了您需要编写的代码总数。政策可与Express/Connect中间件互换,这意味着您可以插入受欢迎的npm模块,如Passport。最后,像Sails中的大多数事情一样,您的策略也可以自动为WebSockets和HTTP工作。
  • 前端无关
虽然“一个语言/框架统治他们”的承诺当然是诱人的,但并不总是现实的。 Sails兼容任何前端策略,无论是Angular,Backbone,iOS/ObjC,Android/Java,Windows Phone还是尚未发明的其他内容。此外,它可以轻松地提供同一个API,以供另一个Web服务或开发人员社区使用。
  • 灵活的资产管道
如果您正在为浏览器构建一个应用程序,那么您将受益匪浅。帆船与Grunt一起出货,这意味着您的整个前端资产工作流程是完全可定制的,并且支持已经在那里的所有伟大的Grunt模块。这包括支持LESS,SASS,Stylus,CoffeeScript,JST,Jade,Handlebars,Dust等等。当您准备投入生产时,您的资产将被自动缩小并自动压缩。您甚至可以编辑静态资产,并将其推送到像CloudFront这样的CDN,以使您的应用程序加载更快。
  • 坚实的基础。
Sails是基于Node.js构建的,这是一种流行的轻量级服务器端技术,允许开发人员在JavaScript中编写快速,可扩展的网络应用程序。 Sails使用Express来处理HTTP请求,并包装用于管理WebSockets的socket.io。所以如果你的应用程序需要真正的低级别,你可以访问原始的Express或者socket.io对象。另一个不错的副作用是您现有的Express路线在Sails应用程序中工作得很好,因此迁移现有的Node应用程序是轻而易举的。(Source Link:http://sailsjs.com/features

Overview

Name With Ownerbalderdashy/sails
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 2)
Platform
License:MIT License
Release Count291
Last Release Namev1.5.10 (Posted on 2024-04-09 18:02:55)
First Release Name12.7.26 (Posted on )
Created At2012-03-18 19:46:15
Pushed At2024-04-23 02:38:28
Last Commit At2024-04-09 18:02:55
Stargazers Count22.8k
Watchers Count649
Fork Count2k
Commits Count7.2k
Has Issues Enabled
Issues Count6382
Issue Open Count506
Pull Requests Count551
Pull Requests Open Count78
Pull Requests Close Count315
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Sails.js logo

Website   Get Started   Docs   News   Submit Issue

NPM version   Gitter   Twitter Follow

Sails.js is a web framework that makes it easy to build custom, enterprise-grade Node.js apps. It is designed to resemble the MVC architecture from frameworks like Ruby on Rails, but with support for the more modern, data-oriented style of web app & API development. It's especially good for building realtime features like chat.

Since version 1.0, Sails supports await out of the box. This replaces nested callbacks (and the commensurate error handling) with simple, familiar usage:

var orgs = await Organization.find();

Installation  

With node installed:

# Get the latest stable release of Sails
$ npm install sails -g
Upgrading from an earlier version of Sails?

Available as of Node >=v7.9 and Sails >=v1.0, ES8's async/await enables dramatic improvements to the way developers build Node.js / Sails apps. It allows server-side JavaScript code to be written with the await keyword, instead of lower-level (and more fragile) flow control mechanisms like nested callbacks and promise chains. It lets developers breathe easier by removing the burden of painstaking, manual error handling after every database query. And best of all, it means the end of "callback hell": the most common source of bugs and stability issues in real world Node.js / Sails applications.

If ES8 isn't for you, don't worry-- Node callbacks and promise chaining are still fully supported. But for most teams, the transition to await results in sizable gains in productivity, with fewer lines of code.

Upgrade guides for all major releases since 2013 are available on the Sails website under Upgrading.

Your First Sails Project

Create a new app:

# Create the app
sails new my-app

Lift sails:

# cd into the new folder
cd my-app

# fire up the server
sails lift

Screenshot from the original Sails video

For the most up-to-date introduction to Sails, get started here.

Compatibility

Sails is built on Node.js, Express, and Socket.io.

Sails actions are compatible with Connect middleware, so in most cases, you can paste code into Sails from an existing Express project and everything will work-- plus you'll be able to use WebSockets to talk to your API, and vice versa.

The ORM, Waterline, has a well-defined adapter system for supporting all kinds of datastores. Officially supported databases include MySQL, PostgreSQL, MongoDB, Redis, and local disk / memory.
Community adapters exist for CouchDB, neDB, TingoDB, SQLite, Oracle, MSSQL, DB2, ElasticSearch, Riak,
neo4j, OrientDB,
Amazon RDS, DynamoDB, Azure Tables, RethinkDB and Solr; for various 3rd-party REST APIs like Quickbooks, Yelp, and Twitter, including a configurable generic REST API adapter; plus some eclectic projects.

For the latest core adapters and notable community adapters, see Available Adapters.

Tutorial Course

Books

Support

Need help or have a question?

Issue Submission

Please read the submission guidelines and code of conduct before opening a new issue. Click here to search/post issues in this repository.

Contribute

There are many different ways you can contribute to Sails:

Please carefully read our contribution guide and check the build status for the relevant branch before submitting a pull request with code changes.

Team

Sails is actively maintained with the help of many amazing contributors. Our core team consists of:

Mike McNeil, Rachael McNeil, John Abrams, Madison Hicks, :---:, :---:, :---:, :---:, :---:
Mike McNeil, Rachael McNeil, John Abrams, Madison Hicks, Our company designs/builds Node.js websites and apps for startups and enterprise customers. After building a few applications and taking them into production, we realized that the Node.js development landscape was very much still the Wild West. Over time, after trying lots of different methodologies, we decided to crystallize all of our best practices into this framework. Six years later, Sails is now one of the most widely-used web application frameworks in the world. I hope it saves you some time! :)

License

MIT License Copyright © 2012-present, Mike McNeil

Sails is built around so many great open-source technologies that it would never have crossed our minds to keep it proprietary. We owe huge gratitude and props to Ryan Dahl (@ry), TJ Holowaychuk (@tj), Doug Wilson (@dougwilson) and Guillermo Rauch (@rauchg) for the work they've done, as well as the stewards of all the other open-source modules we use. Sails could never have been developed without your tremendous contributions to the JavaScript community.

image_squidhome@2x.png

To the top