开发流程
这里面可以看到交互ue出了,就可以出静态api
静态api好处
如果再智能点,静态api是可以对线上api进行测试和压测的。
Get a full fake REST API with zero coding in less than 30 seconds (seriously)
https://github.com/typicode/json-server
Create a db.json file
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
Start JSON Server
$ json-server --watch db.json
Now if you go to http://localhost:3000/posts/1, you'll get
{ "id": 1, "title": "json-server", "author": "typicode" }
https://github.com/base-n/apie
Features
Teck Stacks
https://github.com/base-n/apie/blob/master/routes/api/index.js
var express = require('express');
var router = express.Router();
// console.dir(router)
/* GET home page. */
router.get('/', function(req, res, next) {
res.api({a:1});
});
router.get('/error', function(req, res, next) {
res.api_error({a:1});
});
module.exports = router;
示例
获取课程列表
大家试着补出一下