Feathers哲學
它并不是又一個Javascript框架,也不是一個重復被造的輪子。而是使用service和cross cutting concerns來構建web應用的嘗試。可擴展而又面向服務是它的一大特點,結果會更靈活。它始終堅信,UI、數據或商業邏輯是web應用或移動app的核心,而架構可以幫助實現剩余的工作。
服務的概念
服務層可以幫助解耦應用的接入和呈現,也方便測試。可以為HTTP REST和websocket提供相同的API。
統一接口
好比如REST的一個關鍵約束,命名約定可以見詞知意。對應于REST,有以下方法:GET, POST, PUT, PATCH and DELETE。而服務也有統一的接口。
const myService = {
// GET /path
find(params, callback) {},
// GET /path/
get(id, params, callback) {},
// POST /path
create(data, params, callback) {},
// PUT /path/
update(id, data, params, callback) {},
// PATCH /path/
patch(id, data, params, callback) {},
// DELETE /path/
remove(id, params, callback) {}
}
這個接口讓”hook”到方法執行中以及返回后發射事件更簡單,來提供實時功能。
Hooks
遵循小的模塊做一件事好于大的復雜模塊。然后,可以創建before和after hooks 來把各模塊鏈起來。
站在巨人之肩
Express 4 Feathers繼承了它。
Vorpal Feathers的CLI工具的生成器繼承了它。
Socket.io or Primus Feathers封裝了兩位巨人,來實現web socket傳輸。
mongoose, sequelize, knex, or waterline 服務適配器的ORM的實現。
npm 仍然是包管理工具
passport 完成了很多feathers-authentication的工作。
下面展示了利用Feathers實現的利器,業績Feathers的生態系統。
應用方面
Feathers Chat
Feathers React Native Chat
起步中的項目
Feathers + Apollo
Feathers + React + Mobx
Feathers + React + Webpack
社區插件
。。。
認證
Feathers-accounts
Feathers-service-verify-reset
通信
Feather-batch
數據庫
省略若干字
文檔
Feathers-swagger
多實例
Feathers-cluster
Feathers-sync
Feathers-mailer
Feathers-mailgun
Feathers-sendgrid
回應
Feathers-action
Feathers-action-creators
Feathers-action-reducer
Feathers-action-types
Feathers-react-redux
Feathers-reduxify-services
測試
Feathers-tests-fake-app-users
轉化
Feathers-populate-hook
Feathers-transform-hook
Feathers-virtual-attribute-hook
工具
Feathers-hooks-common
Feathers-hooks-utils
有效性
Feathers-hooks-validate-joi
Feathers-hooks-validatiob-jsonschema
Feathers-tcomb
Feathers-validate-hook
Feathers-validator
視圖層
donees-Feathers
Feathers-done-ssr
Feathers-mithril
Feathers-reactive
ng-Feathers
vue-syncers-Feathers