<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 靜態api ## Why? 開發流程 1. 需求(用戶故事) 2. 交互 3. 靜態api 4. 開發和ui并行 5. 測試、部署等 ![](https://i5ting.github.io/wechat-dev-with-nodejs/vip-lession/img/api-before.png) ![](https://i5ting.github.io/wechat-dev-with-nodejs/vip-lession/img/api-after.png) 這里面可以看到交互ue出了,就可以出靜態api 靜態api好處 * 分析在前,定義好接口規范和字段等 * 有了靜態api,開發也可以并行 * 后端java/node/php * h5/pc * 移動端 如果再智能點,靜態api是可以對線上api進行測試和壓測的。 ## 實現方法 ### json-server Get a full fake REST API with zero coding in less than 30 seconds (seriously) [https://github.com/typicode/json-server](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](http://localhost:3000/posts/1), you'll get ~~~ { "id": 1, "title": "json-server", "author": "typicode" } ~~~ ### apie [https://github.com/base-n/apie](https://github.com/base-n/apie) Features * 代碼極簡,可配置api目錄 * 支持路徑和url映射,在routes目錄下創建api目錄,即可使用/api作為路徑 * 支持v1或v2版本 * 使用express-style的路由,寫法簡單 * 使用res.api約定api返回格式 * 使用req.db(實際是lowdb)模擬數據 Teck Stacks * use base2 as micro kernel * use expess-style routes * use res.api as api convention * use nodemon for livereload [https://github.com/base-n/apie/blob/master/routes/api/index.js](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; ~~~ ## tpl * url :?[http://127.0.0.1:3019/api/](http://127.0.0.1:3019/api/) * method : GET * type : JSON * params : 無 * 返回 * 返回狀態碼 * 返回字段說明 示例 獲取課程列表 * url :?[http://127.0.0.1:3019/api/v1/lessions](http://127.0.0.1:3019/api/v1/lessions) * method : GET * type : JSON * params : 無 * 返回 * 返回狀態碼 * 0 成功 * 返回字段說明 * lessions 對象數組 ## 課程api * 獲取課程列表 * 獲取課程詳情 * 創建訂單 * 我的課程 大家試著補出一下
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看