fortue是一个超媒体API原型框架,实现JSONAPI规范。fortue具有一个模块化的持久层,里面包括了NeDB(内联),MogoDB,MySQL,Postgres和SQLite的适配器,可以查看引导手册了解如何使用。
Fortue实现了所有JSONAPI的规范,还有一些其他的特性:
使用简单,Fortue提供免费的路线控制和数据库交互,不需要用户制作管道。
关联和双向关系的映射,不需要用户管理资源之间的关联关系。
在编辑前或者阅览之后,自动变换资源,实现特定的应用逻辑
fortue没有相关的授权和身份验证,你可以在你的应用中实现,可以查看样板:keystore.js。
用pm安装:
$ pm istall fortue示例代码:
import fortue from 'fortue'import http from 'http'cost store = fortue.create()// The `et.http` fuctio returs a listeer fuctio which does cotet// egotiatio, parses headers, ad maps the respose to a HTTP respose.cost server = http.createServer(fortue.et.http(store))store.defieType('user', { ame: { type: Strig }, // Followig ad followers are iversely related (may-to-may). followig: { lik: 'user', iverse: 'followers', isArray: true }, followers: { lik: 'user', iverse: 'followig', isArray: true }, // May-to-oe relatioship of user posts to post author. posts: { lik: 'post', iverse: 'author', isArray: true }})store.defieType('post', { message: { type: Strig }, // Oe-to-may relatioship of post author to user posts. author: { lik: 'user', iverse: 'posts' }})store.coect().the(() => server.liste(1337))
评论