rapid.js 介绍
rapid.js为您的API请求创建简单,可重用,更简洁的封装,定义自定义路由等等。
安装
yarn add rapid.js
npm i -S rapid.js
npm install --save rapid.js
定义简单模型
const post = new Rapid({ modelName: 'Post' });
post.find(1).then((response) => {
// GET => /api/post/1
});
post.collection.findBy('category','featured').then((response) => {
// GET => /api/posts/category/featured
});
post.withParams({ limit: 20,order: 'desc' }).all().then((response) => {
// GET => /api/posts?limit=20&order=desc
});
post.update(25,{ title: 'Rapid js Is Awesome!' })
// POST => /api/posts/25/update
post.destroy(9)
// POST => /api/posts/9/destroy
post.restore(9)
// POST => /api/posts/9/restore
轻松自定义您的API请求
const post = new Rapid({
modelName: 'Post',
suffixes: {
destroy: '',
update: 'save'
},
methods: {
destroy: 'delete'
},
trailingSlash: true
});
post.update(25,{ title: 'Rapid js Is Awesome!' })
// POST => /api/posts/25/save/
post.destroy(9)
// DELETE => /api/posts/9/
网站地址:https://rapidjs.drewjbartlett.com
GitHub:https://github.com/rapidjs/rapid.js
网站描述:类似ORM的接口和用于API请求的路由器
rapid.js
官方网站:https://rapidjs.drewjbartlett.com
小编说
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。