Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(api): refactor HTTP API to version 2 #735

Merged
merged 37 commits into from
Jan 24, 2024
Merged

refactor(api): refactor HTTP API to version 2 #735

merged 37 commits into from
Jan 24, 2024

Conversation

qwqcode
Copy link
Member

@qwqcode qwqcode commented Jan 2, 2024

⚠️ BREAKING CHANGE

For Developers: The HTTP API has now been updated to version v2, with a lot of adjustments made, such as changing to Restful API style, request type, request body, response body, etc. data structure, adding error response codes. You can refer to #735 or https://artalk.js.org/http-api Please update all your existing clients to adapt to the new v2 server. The new base path is /api/v2/. The UI package's HTTP client has been implemented to auto-generate based on Swagger.json, and there have been a lot of adjustments to the artalk.ctx.getApi() related code. In addition, the HTTP API no longer enforces checks on the header's Origin and Referer (to implement strict isolation of different sites) but still maintains the original CORS origin check.

For General Users: Now all administrators have the same level of authority (there is no longer super admin authority), the function of assigning sub-administrators with independent scope authority to individual sites has been removed, which can simplify the HTTP server maintenance and implementation. Upgrading only requires updating the client and server application at the same time, and there are no additional operations.

变更

API 宏观:

  • 修改为 Restful API 风格
  • 请求类型从 FormData 改为 JSON
  • 修改整理请求体、响应体数据结构
  • 为错误响应加上 HTTP Code
  • 整理拆分 API 以解耦实现
  • 提高可测试性
  • 使用 Swagger.json 自动生成 HTTP Client 不再自写

功能实现:

  • 不再强制检查站点隔离的 Origin
  • 移除为管理员分配站点名的站点隔离功能,简化实现
  • 优化 GET /comments 接口实现

@qwqcode qwqcode added the enhancement New feature or request label Jan 2, 2024
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

Attention: 1053 lines in your changes are missing coverage. Please review.

Comparison is base (9ba9439) 50.29% compared to head (3d591a5) 34.78%.

Files Patch % Lines
server/handler/comment_update.go 0.00% 94 Missing ⚠️
server/handler/comment_list.go 0.00% 92 Missing ⚠️
server/handler/site_update.go 0.00% 52 Missing ⚠️
server/handler/user_update.go 0.00% 45 Missing ⚠️
server/handler/page_update.go 0.00% 43 Missing ⚠️
server/handler/captcha_verify.go 0.00% 42 Missing ⚠️
server/handler/user_create.go 0.00% 37 Missing ⚠️
server/handler/user_list.go 0.00% 34 Missing ⚠️
server/handler/user_info.go 0.00% 33 Missing ⚠️
server/handler/stat.go 0.00% 32 Missing ⚠️
... and 34 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #735       +/-   ##
===========================================
- Coverage   50.29%   34.78%   -15.51%     
===========================================
  Files          70      115       +45     
  Lines        3271     4695     +1424     
===========================================
- Hits         1645     1633       -12     
- Misses       1521     2959     +1438     
+ Partials      105      103        -2     
Flag Coverage Δ
go 34.78% <0.18%> (-15.51%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qwqcode qwqcode merged commit 589850d into master Jan 24, 2024
10 of 12 checks passed
@qwqcode qwqcode deleted the refactor/api branch January 24, 2024 13:33
qwqcode added a commit that referenced this pull request Jan 24, 2024
BREAKING CHANGE: For Developers: The HTTP API has now been updated to version v2, with a lot of adjustments made, such as changing to Restful API style, request type, request body, response body, etc. data structure, adding error response codes. You can refer to #735 or https://artalk.js.org/http-api Please update all your existing clients to adapt to the new v2 server. The new base path is `/api/v2/`. The UI package's HTTP client has been implemented to auto-generate based on `Swagger.json`, and there have been a lot of adjustments to the `artalk.ctx.getApi()` related code. In addition, the HTTP API no longer enforces checks on the header's `Origin` and `Referer` (to implement strict isolation of different sites) but still maintains the original CORS origin check.

For General Users: Now all administrators have the same level of authority (there is no longer super admin authority), the function of assigning sub-administrators with independent scope authority to individual sites has been removed, which can simplify the HTTP server maintenance and implementation. Upgrading only requires updating the client and server application at the same time, and there are no additional operations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant