Web应用的高级I/O库:Fortune.js

nf83 9年前


Fortune是Web应用程序的一个高级I/O库。它提供了entity-relationship modelling的一个实现,是无关数据存储的,可用于实现实时(WebSocket) 和 超媒体应用(RMM Level 3).

示例

Let's build an API that models 推ter's basic functionality:

import fortune from 'fortune'  import http from 'http'    const store = fortune.create()    // The `net.http` function returns a listener function which does content  // negotiation, parses headers, and maps the response to an HTTP response.  const server = http.createServer(fortune.net.http(store))    store.defineType('user', {    name: { type: String },      // Following and followers are inversely related (many-to-many).    following: { link: 'user', inverse: 'followers', isArray: true },    followers: { link: 'user', inverse: 'following', isArray: true },      // Many-to-one relationship of user posts to post author.    posts: { link: 'post', inverse: 'author', isArray: true }  })    store.defineType('post', {    message: { type: String },      // One-to-many relationship of post author to user posts.    author: { link: 'user', inverse: 'posts' }  })    store.connect().then(() => server.listen(1337))

项目主页:http://www.open-open.com/lib/view/home/1440639728700