实时JavaScript框架 Feathers

码农软件 · 软件分类 · JavaScript MVC 框架 · 2019-03-15 13:27:53

软件介绍

Feathers logo

Feathers是一个为将来应用程序准备的实时JavaScript框架。

开始安装

你可以仅利用4个命令建立第一个实时API:

$ npm install -g yo generator-feathers
$ mkdir my-new-app
$ cd my-new-app/
$ yo feathers
$ npm start

要了解更多关于Feathers请访问 feathersjs.com 官网直接进入the Feathers docs

看看如何工作

这里是所有你需要在内存数据存储中创建REST风格,实时消息API使用的代码:

// app.js
var feathers = require('feathers');
var rest = require('feathers-rest');
var socketio = require('feathers-socketio');
var memory = require('feathers-memory');
var bodyParser = require('body-parser');
var handler = require('feathers-errors/handler');

// A Feathers app is the same as an Express app
var app = feathers();

// Add REST API support
app.configure(rest());
// Configure Socket.io real-time APIs
app.configure(socketio());
// Parse HTTP JSON bodies
app.use(bodyParser.json());
// Parse URL-encoded params
app.use(bodyParser.urlencoded({ extended: true }));
// Register our memory "messages" service
app.use('/messages', memory());
// Register a nicer error handler than the default Express one
app.use(handler());
// Start the server
app.listen(3000);

然后运行

npm install feathers feathers-rest feathers-socketio feathers-errors feathers-memory body-parser
node app

并访问http://localhost:3000/messages。 那就行了!利用Feathers你还可以做更多包括;使用一个真实数据库,认证,授权,集群等等!跳转到the Feathers docs,看看它是多么容易建立可扩展的实时应用程序。

本文地址:https://codercto.com/soft/d/1401.html

Implementing Responsive Design

Implementing Responsive Design

Tim Kadlec / New Riders / 2012-7-31 / GBP 27.99

New devices and platforms emerge daily. Browsers iterate at a remarkable pace. Faced with this volatile landscape we can either struggle for control or we can embrace the inherent flexibility of the w......一起来看看 《Implementing Responsive Design》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具