{"id":6805,"date":"2025-07-09T15:20:20","date_gmt":"2025-07-09T07:20:20","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6805"},"modified":"2025-07-09T15:20:20","modified_gmt":"2025-07-09T07:20:20","slug":"bff-%e7%9a%84-server-%e5%92%8c%e4%bc%a0%e7%bb%9f%e5%90%8e%e7%ab%af-server-%e6%9c%89%e4%bb%80%e4%b9%88%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6805","title":{"rendered":"BFF \u7684 Server \u548c\u4f20\u7edf\u540e\u7aef Server \u6709\u4ec0\u4e48\u533a\u522b"},"content":{"rendered":"<p>BFF\uff08Backend for Frontend\uff0c\u670d\u52a1\u4e8e\u524d\u7aef\u7684\u540e\u7aef\uff09\u662f\u4e00\u79cd\u4e3a\u7279\u5b9a\u524d\u7aef\u573a\u666f\u4f18\u5316\u7684\u540e\u7aef\u67b6\u6784\u6a21\u5f0f\uff0c\u4e0e\u4f20\u7edf\u540e\u7aef Server \u76f8\u6bd4\uff0c\u5176\u8bbe\u8ba1\u76ee\u6807\u3001\u804c\u8d23\u548c\u5b9e\u73b0\u65b9\u5f0f\u5b58\u5728\u663e\u8457\u5dee\u5f02\u3002\u4ee5\u4e0b\u662f\u6838\u5fc3\u5bf9\u6bd4\uff1a<\/p>\n<h3>\u4e00\u3001\u6838\u5fc3\u533a\u522b<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u7ef4\u5ea6<\/th>\n<th>\u4f20\u7edf\u540e\u7aef Server<\/th>\n<th>BFF Server<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u8bbe\u8ba1\u76ee\u6807<\/strong><\/td>\n<td>\u901a\u7528\u670d\u52a1\uff0c\u9762\u5411\u591a\u4e2a\u5ba2\u6237\u7aef\uff08Web\u3001App\u3001\u7b2c\u4e09\u65b9\uff09<\/td>\n<td>\u4e3a\u7279\u5b9a\u524d\u7aef\u573a\u666f\u5b9a\u5236\uff0c\u5982 Web\u3001iOS\u3001\u5c0f\u7a0b\u5e8f<\/td>\n<\/tr>\n<tr>\n<td><strong>\u804c\u8d23\u8303\u56f4<\/strong><\/td>\n<td>\u5904\u7406\u4e1a\u52a1\u903b\u8f91\u3001\u6570\u636e\u6301\u4e45\u5316\u3001\u6743\u9650\u6821\u9a8c\u7b49<\/td>\n<td>\u805a\u5408\u670d\u52a1\u3001\u6570\u636e\u9002\u914d\u3001UI \u903b\u8f91\u7f16\u6392<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6570\u636e\u683c\u5f0f<\/strong><\/td>\n<td>\u8fd4\u56de\u901a\u7528\u6570\u636e\u7ed3\u6784\uff08\u5982 REST API\uff09<\/td>\n<td>\u8fd4\u56de\u9002\u914d\u524d\u7aef\u7684\u5b9a\u5236\u6570\u636e\u7ed3\u6784<\/td>\n<\/tr>\n<tr>\n<td><strong>\u53d8\u66f4\u9891\u7387<\/strong><\/td>\n<td>\u76f8\u5bf9\u7a33\u5b9a\uff0c\u907f\u514d\u9891\u7e41\u4fee\u6539<\/td>\n<td>\u968f\u524d\u7aef\u9700\u6c42\u5feb\u901f\u8fed\u4ee3<\/td>\n<\/tr>\n<tr>\n<td><strong>\u90e8\u7f72\u65b9\u5f0f<\/strong><\/td>\n<td>\u901a\u5e38\u72ec\u7acb\u90e8\u7f72\u4e3a\u5fae\u670d\u52a1<\/td>\n<td>\u5e38\u4e0e\u524d\u7aef\u7ed1\u5b9a\u90e8\u7f72\uff08\u5982\u540c\u4e00 CI\/CD \u6d41\u6c34\u7ebf\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e8c\u3001\u67b6\u6784\u804c\u8d23\u5bf9\u6bd4<\/h3>\n<h4>1. \u4f20\u7edf\u540e\u7aef Server<\/h4>\n<ul>\n<li><strong>\u7279\u70b9<\/strong>\uff1a\n<ul>\n<li>\u63d0\u4f9b\u901a\u7528\u63a5\u53e3\uff08\u5982 REST API\uff09\uff0c\u4e0d\u5173\u5fc3\u8c03\u7528\u65b9\u662f\u8c01\u3002<\/li>\n<li>\u5305\u542b\u5b8c\u6574\u7684\u4e1a\u52a1\u903b\u8f91\u3001\u6570\u636e\u8bbf\u95ee\u5c42\uff08\u5982\u6570\u636e\u5e93\u64cd\u4f5c\uff09\u3002<\/li>\n<li>\u6ce8\u91cd\u590d\u7528\u6027\u548c\u7a33\u5b9a\u6027\uff0c\u53d8\u66f4\u6210\u672c\u9ad8\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u793a\u4f8b<\/strong>\uff1a\n<pre><code>GET \/api\/users\/{id} \u2192 \u8fd4\u56de\u901a\u7528\u7528\u6237\u4fe1\u606f\uff08id\u3001name\u3001email\u3001createTime\uff09<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>2. BFF Server<\/h4>\n<ul>\n<li><strong>\u7279\u70b9<\/strong>\uff1a\n<ul>\n<li>\u4e3a\u7279\u5b9a\u524d\u7aef\u5b9a\u5236\u63a5\u53e3\uff0c\u53ef\u80fd\u805a\u5408\u591a\u4e2a\u540e\u7aef\u670d\u52a1\u7684\u6570\u636e\u3002<\/li>\n<li>\u5904\u7406 UI \u76f8\u5173\u903b\u8f91\uff08\u5982\u6570\u636e\u683c\u5f0f\u5316\u3001\u6743\u9650\u88c1\u526a\u3001\u52a0\u8f7d\u72b6\u6001\uff09\u3002<\/li>\n<li>\u5feb\u901f\u54cd\u5e94\u524d\u7aef\u9700\u6c42\u53d8\u5316\uff0c\u8fed\u4ee3\u9891\u7e41\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u793a\u4f8b<\/strong>\uff1a\n<pre><code>\/\/ \u4e3a\u79fb\u52a8\u7aef\u4f18\u5316\u7684\u63a5\u53e3\nGET \/bff\/mobile\/users\/{id} \u2192 \u8fd4\u56de\u7cbe\u7b80\u7528\u6237\u4fe1\u606f\uff08id\u3001name\u3001avatar\uff09+ \u4e2a\u6027\u5316\u63a8\u8350\u5185\u5bb9<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u9002\u7528\u573a\u666f<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u573a\u666f<\/th>\n<th>\u4f20\u7edf\u540e\u7aef Server<\/th>\n<th>BFF Server<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u591a\u7aef\u5dee\u5f02\u5927<\/strong><\/td>\n<td>\u9700\u524d\u7aef\u9002\u914d\u4e0d\u540c\u6570\u636e\u7ed3\u6784<\/td>\n<td>\u5404\u7aef\u6709\u72ec\u7acb BFF\uff0c\u51cf\u5c11\u524d\u7aef\u9002\u914d\u6210\u672c<\/td>\n<\/tr>\n<tr>\n<td><strong>UI \u903b\u8f91\u590d\u6742<\/strong><\/td>\n<td>\u96be\u4ee5\u5904\u7406\uff08\u5982\u591a API \u805a\u5408\u3001\u52a0\u8f7d\u6001\uff09<\/td>\n<td>\u53ef\u5728 BFF \u5c42\u7edf\u4e00\u5904\u7406<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5feb\u901f\u8fed\u4ee3<\/strong><\/td>\n<td>\u53d8\u66f4\u5f71\u54cd\u8303\u56f4\u5927<\/td>\n<td>\u72ec\u7acb\u8fed\u4ee3\uff0c\u4e0d\u5f71\u54cd\u5176\u4ed6\u7aef<\/td>\n<\/tr>\n<tr>\n<td><strong>\u6027\u80fd\u4f18\u5316<\/strong><\/td>\n<td>\u6570\u636e\u5197\u4f59\uff08\u591a\u7aef\u8fd4\u56de\u76f8\u540c\u5b57\u6bb5\uff09<\/td>\n<td>\u6309\u9700\u8fd4\u56de\uff0c\u51cf\u5c11\u4f20\u8f93\u6570\u636e\u91cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u56db\u3001\u6280\u672f\u5b9e\u73b0\u5bf9\u6bd4<\/h3>\n<h4>1. \u4f20\u7edf\u540e\u7aef Server<\/h4>\n<ul>\n<li><strong>\u6280\u672f\u6808<\/strong>\uff1aSpring Boot\u3001Node.js\uff08Express\uff09\u3001Django \u7b49\u3002<\/li>\n<li><strong>\u5178\u578b\u67b6\u6784<\/strong>\uff1a\n<pre><code>\u5ba2\u6237\u7aef \u2192 API Gateway \u2192 \u4e1a\u52a1\u670d\u52a1\uff08UserService\u3001OrderService\uff09 \u2192 \u6570\u636e\u5e93<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>2. BFF Server<\/h4>\n<ul>\n<li><strong>\u6280\u672f\u6808<\/strong>\uff1a\n<ul>\n<li>Node.js\uff08Next.js API Routes\u3001NestJS\uff09\uff1a\u9002\u5408\u524d\u7aef\u56e2\u961f\u7ef4\u62a4\uff0c\u4e0e\u524d\u7aef\u6280\u672f\u6808\u4e00\u81f4\u3002<\/li>\n<li>GraphQL\uff1a\u7075\u6d3b\u7684\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff0c\u53ef\u6309\u9700\u83b7\u53d6\u6570\u636e\u3002<\/li>\n<li>\u5fae\u524d\u7aef\u6846\u67b6\uff08\u5982 Single-SPA\uff09\uff1a\u4e0e\u524d\u7aef\u6846\u67b6\u6df1\u5ea6\u96c6\u6210\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5178\u578b\u67b6\u6784<\/strong>\uff1a\n<pre><code>\u79fb\u52a8\u7aef \u2192 Mobile BFF \u2192 API Gateway \u2192 \u4e1a\u52a1\u670d\u52a1\nWeb \u7aef \u2192 Web BFF \u2192 API Gateway \u2192 \u4e1a\u52a1\u670d\u52a1<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>\u4e94\u3001\u4f18\u7f3a\u70b9<\/h3>\n<table>\n<thead>\n<tr>\n<th>\u7c7b\u578b<\/th>\n<th>\u4f18\u70b9<\/th>\n<th>\u7f3a\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u4f20\u7edf\u540e\u7aef<\/strong><\/td>\n<td>\u590d\u7528\u6027\u9ad8\u3001\u67b6\u6784\u7edf\u4e00\u3001\u7ef4\u62a4\u6210\u672c\u4f4e<\/td>\n<td>\u96be\u4ee5\u9002\u914d\u591a\u7aef\u5dee\u5f02\uff0c\u524d\u7aef\u9002\u914d\u6210\u672c\u9ad8<\/td>\n<\/tr>\n<tr>\n<td><strong>BFF<\/strong><\/td>\n<td>\u524d\u7aef\u4f53\u9a8c\u4f18\u5316\u3001\u8fed\u4ee3\u7075\u6d3b\u3001\u51cf\u5c11\u6570\u636e\u5197\u4f59<\/td>\n<td>\u670d\u52a1\u6570\u91cf\u589e\u591a\u3001\u67b6\u6784\u590d\u6742\u5ea6\u4e0a\u5347<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<p>BFF \u662f\u4e3a\u89e3\u51b3<strong>\u591a\u7aef\u5dee\u5f02\u5316\u9700\u6c42<\/strong>\u548c<strong>\u524d\u7aef\u5feb\u901f\u8fed\u4ee3<\/strong>\u800c\u8bde\u751f\u7684\u67b6\u6784\u6a21\u5f0f\uff0c\u5b83\u901a\u8fc7\u5c06 UI \u76f8\u5173\u903b\u8f91\u4ece\u4f20\u7edf\u540e\u7aef\u5265\u79bb\uff0c\u4f7f\u524d\u7aef\u56e2\u961f\u80fd\u66f4\u81ea\u4e3b\u5730\u63a7\u5236\u6570\u636e\u83b7\u53d6\u548c\u5904\u7406\u65b9\u5f0f\u3002\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u901a\u5e38\u4f1a<strong>\u6df7\u5408\u4f7f\u7528<\/strong>\u4f20\u7edf\u540e\u7aef\u548c BFF\uff1a<\/p>\n<ul>\n<li><strong>\u6838\u5fc3\u4e1a\u52a1\u903b\u8f91<\/strong>\uff1a\u7531\u4f20\u7edf\u540e\u7aef\u670d\u52a1\u5904\u7406\uff0c\u4fdd\u8bc1\u7a33\u5b9a\u6027\u548c\u590d\u7528\u6027\uff1b<\/li>\n<li><strong>\u524d\u7aef\u7279\u5b9a\u9700\u6c42<\/strong>\uff1a\u7531 BFF \u5c42\u5904\u7406\uff0c\u63d0\u4f9b\u5b9a\u5236\u5316\u63a5\u53e3\u3002<\/li>\n<\/ul>\n<p>\u9009\u62e9\u54ea\u79cd\u67b6\u6784\u9700\u6839\u636e\u9879\u76ee\u89c4\u6a21\u3001\u56e2\u961f\u80fd\u529b\u548c\u4e1a\u52a1\u7279\u6027\u7efc\u5408\u5224\u65ad\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>BFF\uff08Backend for Frontend\uff0c\u670d\u52a1\u4e8e\u524d\u7aef\u7684\u540e\u7aef\uff09\u662f\u4e00\u79cd\u4e3a\u7279\u5b9a\u524d\u7aef\u573a\u666f\u4f18\u5316\u7684\u540e\u7aef\u67b6\u6784\u6a21\u5f0f\uff0c\u4e0e&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6805\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135],"tags":[],"class_list":["post-6805","post","type-post","status-publish","format-standard","hentry","category-135"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6805"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6805\/revisions"}],"predecessor-version":[{"id":6806,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6805\/revisions\/6806"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}