Skip to content

Commit 46a0a3a

Browse files
committed
docs: update docs
- add `CHANGELOG` - add `CONTRIBUTING` - add favicon
1 parent d9b7423 commit 46a0a3a

File tree

11 files changed

+249
-71
lines changed

11 files changed

+249
-71
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- The content will be also use in `docs/CHANGELOG/CHANGELOG.md` by `pymdownx.snippets` -->
2+
<!-- Do not use any **relative link** and **GitHub-specific syntax** !-->
3+
<!-- Do not rename or move the file -->
4+
5+
# Changelog
6+
7+
All notable changes to this project will be documented in this file.
8+
9+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
10+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)(**After we publish 1.0.0**).
11+
12+
- `Added` for new features.
13+
- `Changed` for changes in existing functionality.
14+
- `Deprecated` for soon-to-be removed features.
15+
- `Removed` for now removed features.
16+
- `Fixed` for any bug fixes.
17+
- `Security` in case of vulnerabilities.
18+
19+
<!-- Refer to: https://github.com/olivierlacan/keep-a-changelog/blob/main/CHANGELOG.md -->
20+
<!-- Refer to: https://github.com/gradio-app/gradio/blob/main/CHANGELOG.md -->
21+
22+
## [Unreleased]
23+
24+
None.
25+
26+
## [0.0.1b0] - 2023-11-27 [YANKED]
27+
28+
!!! danger
29+
**This version has security vulnerabilities, please stop using it.**
30+
31+
[unreleased]: https://github.com/WSH032/fastapi-proxy-lib/compare/v0.0.1b0...HEAD
32+
[0.0.1b0]: https://github.com/WSH032/fastapi-proxy-lib/releases/tag/v0.0.1b0

CONTRIBUTING.md

Lines changed: 165 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,183 @@
1-
# Hi 感谢对本项目感兴趣
1+
<!-- The content will be also use in `docs/CONTRIBUTING/CONTRIBUTING.md` by `pymdownx.snippets` -->
2+
<!-- Do not use any **relative link** and **GitHub-specific syntax** !-->
3+
<!-- Do not rename or move the file -->
24

3-
## 代码贡献
5+
# Contributing
46

5-
> **Note**
6-
>
7-
> 我们最低支持的版本是`python3.8`,你可以随意使用`python3.8`以上的版本。
8-
>
9-
> 但是请注意,您的代码要能通过`py >= 3.8`的所有版本的代码风格检查与测试。
7+
> The guide is modified from [mkdocstrings](https://mkdocstrings.github.io/contributing/#contributing)
108
11-
我们推荐使用[虚拟环境](https://docs.python.org/3/library/venv.html#creating-virtual-environments)来进行开发
9+
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
1210

13-
在激活虚拟环境后,运行[./scripts/init.sh](./scripts/init-dev.sh)来为你初始化:
11+
## Environment setup
1412

15-
- [requirements](./requirements-dev.txt)
16-
- [hatch](https://github.com/pypa/hatch)
17-
- [pre-commit](https://pre-commit.com/)
18-
- [mkdocs-material](https://squidfunk.github.io/mkdocs-material/)
13+
First, `fork` and `clone` the repository, then `cd` to the directory.
1914

20-
## 代码风格
15+
We use [`hatch`](https://github.com/pypa/hatch) and [`pre-commit`](https://pre-commit.com/) to manage our project.
2116

22-
由于本项目主要是python语言,所以我们只强制要求python代码风格。
17+
You can install them with:
2318

24-
但是涉及到其他语言(例如 `bash`, `toml` 等)的部分,也请尽力保证样式正确。
19+
```shell
20+
# https://pypa.github.io/pipx/
21+
python3 -m pip install --user pipx
2522

26-
> **Note**
27-
> 我们启用了大量而严格的`lint`规则,如果你使用`vscode`,我们推荐你安装[./.vscode/extensions.json](./.vscode/extensions.json)中的插件来帮助你实时检查错误
28-
>
29-
> 如果你打不过检查器,可以使用`# noqa``# type: ignore`来跳过检查
30-
>
31-
> 当然,这些规则可能过于严格,你可以发起一个`issue`或者`pull request`来讨论是否需要修改规则
23+
pipx install hatch
24+
pipx install pre-commit
25+
```
3226

33-
### python代码风格(请查看[./pyproject.toml](./pyproject.toml)了解我们的风格)
27+
Then, initialize the env with:
3428

35-
- [Ruff](https://github.com/astral-sh/ruff): 代码质量检查
36-
- [Blcak](https://github.com/psf/black): 代码格式规范
37-
- [Pyright](https://github.com/Microsoft/pyright/): 静态类型检查
29+
```shell
30+
# Init pre-commit
31+
# https://pre-commit.com/#3-install-the-git-hook-scripts
32+
pre-commit install
33+
pre-commit run --all-files
3834

39-
您需要通过以上检查,`pre-commit` 会确保这点。
35+
# https://hatch.pypa.io/latest/environment/
36+
hatch shell
37+
```
4038

41-
你也可以[手动检查](./scripts/lint.sh)[自动修复](./scripts/format.sh)
39+
That's all! Now, you can start to develop.
4240

43-
> **Note**
44-
> `Pyright`检查将发生两次
45-
>
46-
> -`pre-commit`中,`Pyright`不会检查第三方依赖,并且`python`版本为支持的最低版本
47-
> - 而在`Github Actions`[手动检查](./scripts/lint.sh)中,`Pyright`将在激活的虚拟环境中检查所有依赖
41+
## Code style
4842

49-
## 代码测试
43+
The source code is in `src/`
5044

51-
测试文件位于[./tests/](./tests/)
45+
We use [Ruff](https://github.com/astral-sh/ruff), [Blcak](https://github.com/psf/black), [Pyright](https://github.com/Microsoft/pyright/)
46+
and [Codespell](https://github.com/codespell-project/codespell) to check our code style and lint.
5247

53-
我们使用`pytest`来完成测试,测试将在`Github Actions`中进行。
48+
Please check `pyproject.toml` to know our style.
5449

55-
你也可以[手动测试](./scripts/pytest.sh)
50+
If you want to format or lint-fix your code, you can use the following command:
51+
52+
```shell
53+
hatch run lint
54+
```
55+
56+
or, with `pre-commit`:
57+
58+
```shell
59+
pre-commit run -a
60+
```
61+
62+
or, dry run:
63+
64+
```shell
65+
hatch run lint-check
66+
```
67+
68+
!!! tip
69+
If you use `VSCode`, we strongly recommend you to install the extensions in `.vscode/extensions.json`.<br>
70+
Because our code style rules are quite strict.<br>
71+
These extensions can help you know where need to be fixed when coding.
72+
73+
## Testing
74+
75+
We use [pytest](https://docs.pytest.org/en/stable/) to test our code.
76+
77+
The test source code is in `tests/`
78+
79+
You can run the testing with:
80+
81+
```shell
82+
hatch run test
83+
```
84+
85+
## Documentation
86+
87+
We use [mkdocs](https://www.mkdocs.org), [mkdocs-material](https://squidfunk.github.io/mkdocs-material), [mkdocstrings](https://mkdocstrings.github.io) to build our documentation.
88+
89+
The documentation source code is in `docs/`, `mkdocs.yml`,
90+
may be there is also some source code in `scripts/` or somewhere (check `mkdocs.yml` to find that).
91+
92+
Live-reloading docs:
93+
94+
```shell
95+
hatch run docs:mkdocs serve
96+
```
97+
98+
Build docs:
99+
100+
```shell
101+
hatch run docs:docs-build
102+
```
103+
104+
## PR
105+
106+
- PRs should target the `main` branch.
107+
- Keep branches up to date by `rebase` before merging.
108+
- Do not add multiple unrelated things in same PR.
109+
- Do not submit PRs where you just take existing lines and reformat them without changing what they do.
110+
- Do not change other parts of the code that are not yours for formatting reasons.
111+
- Do not use your clone's main branch to make a PR - create a branch and PR that.
112+
113+
### Edit `CHANGELOG.md`
114+
115+
If you have made the corresponding changes, please record them in `CHANGELOG.md`.
116+
117+
### Commit message convention
118+
119+
Commit messages must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/),
120+
or, `pre-commit` may be reject your commit.
121+
122+
!!! info
123+
If you don't know how to finish these, it's okay, feel free to initiate a PR, I will help you continue.
124+
125+
## More
126+
127+
There may still be some useful commands in `pyproject.toml`, you can refer to [hatch/environment/scripts](https://hatch.pypa.io/latest/config/environment/overview/#scripts) to use them.
128+
129+
!!! info
130+
If you find that the commands given in the above examples are incorrect, please open an issue, we greatly appreciate it.
131+
132+
---
133+
134+
## 😢
135+
136+
!!! warning
137+
The following 👇 content is for the maintainers of this project, may be you don't need to read it.
138+
139+
---
140+
141+
## deploy-docs
142+
143+
please refer to `.github/workflows/docs.yml`
144+
145+
## CI: lint-test
146+
147+
please refer to `.github/workflows/lint-test.yml`
148+
149+
## CI: pre-commit-ci auto-update
150+
151+
Every Monday, `pre-commit-ci` will send a PR for automatic hook version updates, which will trigger a local `ver_sync` hook.
152+
153+
The `ver_sync` hook will maintain lint tools version consistency between `.pre-commit-config.yaml` and `pyproject.toml`.
154+
155+
Please check whether the `ver_sync` works properly, then you can accept the PR.
156+
157+
## Publish and Release 🚀
158+
159+
**^^First, edit `CHANGELOG.md` to record the changes.^^**
160+
161+
Then, please refer to:
162+
163+
- `.github/workflows/publish.yml`
164+
- <https://github.com/frankie567/hatch-regex-commit>
165+
- <https://hatch.pypa.io/latest/version/#updating>
166+
167+
Update version with:
168+
169+
```shell
170+
hatch version {new_version}
171+
```
172+
173+
It will create a commit and tag automatically, then, push the **tag** to GitHub.
174+
175+
After that, the `publish.yml` workflow will build and publish the package to PyPI.
176+
177+
> Don't forget to make a `approve` in environment `pypi` for the workflow.
178+
179+
Finally, edit the `draft release` created by `publish.yml` workflow, and publish the release.
180+
181+
!!! warning
182+
The creating of tag needs signature verification,<br>
183+
please refer to <https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification>

README.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
<!-- The content will be also use in `docs/index.md` by `pymdownx.snippets` -->
2+
<!-- Do not use any **relative link** and **GitHub-specific syntax** !-->
3+
<!-- Do not rename or move the file -->
4+
15
# FastAPI Proxy Lib
26

37
<p align="center">
48
<em>HTTP/WebSocket proxy for starlette/FastAPI</em>
59
</p>
610

7-
| | |
8-
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
9-
| CI/CD | [![CI: lint-test]][CI: lint-test#link] [![CI: docs]][CI: docs#link] |
11+
| | |
12+
| - | - |
13+
| CI/CD | [![CI: lint-test]][CI: lint-test#link] [![pre-commit.ci status]][pre-commit.ci status#link] <br> [![CI: docs]][CI: docs#link] [![CI: publish]][CI: publish#link] |
1014
| Code | [![codecov]][codecov#link] [![Code style: black]][Code style: black#link] [![Ruff]][Ruff#link] [![Checked with pyright]][Checked with pyright#link] |
11-
| Package | [![Python-Version]][Python-Version#link] |
12-
| Meta | [![Hatch project]][Hatch project#link] [![GitHub License]][GitHub License#link] |
15+
| Package | [![PyPI - Version]][PyPI#link] [![PyPI - Downloads]][PyPI#link] [![PyPI - Python Version]][PyPI#link] |
16+
| Meta | [![Hatch project]][Hatch project#link] [![GitHub License]][GitHub License#link] |
1317

1418
---
1519

@@ -48,13 +52,12 @@ So, it perfectly supports all features of [httpx.AsyncClient](https://www.python
4852
> !!! note
4953
>
5054
> We follow semantic versioning.<br>
51-
> This is a young project, and before 1.0.0, there may be changes in the API (though we try to avoid that).<br>
52-
> We recommend pinning to any minor versions, such as 0.1.x.
53-
54-
Pypi will come soon, please install from github temporarily:
55+
> This is a young project, and before 1.0.0, there may be changes in the API (we try to avoid that).<br>
56+
> We will release security updates at any time, please try to keep the version updated, instead of pinning to the old version.<br>
57+
> pin to `major version` is recommended.
5558
5659
```shell
57-
pip install fastapi-proxy-lib[standard]@git+https://github.com/WSH032/fastapi-proxy-lib.git
60+
pip install fastapi-proxy-lib
5861
```
5962

6063
Perhaps you've noticed that we're installing `fastapi-proxy-lib[standard]` instead of `fastapi-proxy-lib`. The difference is:
@@ -82,31 +85,39 @@ uvicorn main:app --host 127.0.0.1 --port 8000
8285

8386
Then, visit `http://127.0.0.1:8000/bar?baz=1`, you will get the response from `http://www.example.com/foo/bar?baz=1`.
8487

85-
For support with `FastAPI router` or only using `Starlette`, please **visit to our [documentation 📚](https://wsh032.github.io/fastapi-proxy-lib/) for more details**.
88+
**[Continue, please visit to our documentation 📚 for more details](https://wsh032.github.io/fastapi-proxy-lib/)**:
89+
90+
- support for `FastAPI router`
91+
- only `Starlette` dependency
92+
- `WebSocket` proxy
8693

8794
## development
8895

8996
- If you find any issues, please don't hesitate to [open an issue](https://github.com/WSH032/fastapi-proxy-lib/issues).
9097
- If you need assistance, feel free to [start a discussion](https://github.com/WSH032/fastapi-proxy-lib/discussions).
91-
- [Welcome PR](https://github.com/WSH032/fastapi-proxy-lib/pulls)
98+
- Follow our `CONTRIBUTING.md`, [PR Welcome!](https://github.com/WSH032/fastapi-proxy-lib/pulls)
99+
- Security 😰❗: We value any security vulnerabilities, [please report to us privately](https://github.com/WSH032/fastapi-proxy-lib/security), pretty appreciated for that.
92100

93101
English is not the native language of the author (me), so if you find any areas for improvement in the documentation, your feedback is welcome.
94102

95-
If you think this project helpful, consider giving it a star ![GitHub Repo stars](https://img.shields.io/github/stars/wsh032/fastapi-proxy-lib?style=social)
96-
, which makes me happy. :smile:
103+
If you think this project helpful, consider giving it a star ![GitHub Repo stars](https://img.shields.io/github/stars/wsh032/fastapi-proxy-lib?style=social), which makes me happy. :smile:
97104

98105
## License
99106

100107
This project is licensed under the terms of the *Apache License 2.0*.
101108

102109
<!-- link -->
103110

111+
<!-- ci/cd -->
104112
[CI: lint-test]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/lint-test.yml/badge.svg?branch=main
105113
[CI: lint-test#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/lint-test.yml
106114
[CI: docs]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/docs.yml/badge.svg?branch=main
107115
[CI: docs#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/docs.yml
108-
[Python-Version]: https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FWSH032%2Ffastapi-proxy%2Fmain%2Fpyproject.toml&logo=python&logoColor=gold&label=Python
109-
[Python-Version#link]: https://github.com/WSH032/fastapi-proxy-lib/blob/main/pyproject.toml
116+
[CI: publish]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/publish.yml/badge.svg?branch=main
117+
[CI: publish#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/publish.yml
118+
[pre-commit.ci status]: https://results.pre-commit.ci/badge/github/WSH032/fastapi-proxy-lib/main.svg
119+
[pre-commit.ci status#link]: https://results.pre-commit.ci/latest/github/WSH032/fastapi-proxy-lib/main
120+
<!-- code -->
110121
[Code style: black]: https://img.shields.io/badge/code%20style-black-000000.svg
111122
[Code style: black#link]: https://github.com/psf/black
112123
[GitHub License]: https://img.shields.io/github/license/WSH032/fastapi-proxy-lib?color=9400d3
@@ -115,6 +126,12 @@ This project is licensed under the terms of the *Apache License 2.0*.
115126
[Ruff#link]: https://github.com/astral-sh/ruff
116127
[Checked with pyright]: https://microsoft.github.io/pyright/img/pyright_badge.svg
117128
[Checked with pyright#link]: https://microsoft.github.io/pyright
129+
<!-- package -->
130+
[PyPI - Version]: https://img.shields.io/pypi/v/fastapi-proxy-lib?logo=pypi&label=PyPI&logoColor=gold
131+
[PyPI - Downloads]: https://img.shields.io/pypi/dm/fastapi-proxy-lib?color=blue&label=Downloads&logo=pypi&logoColor=gold
132+
[PyPI - Python Version]: https://img.shields.io/pypi/pyversions/fastapi-proxy-lib?logo=python&label=Python&logoColor=gold
133+
[PyPI#link]: https://pypi.org/project/fastapi-proxy-lib
134+
<!-- meta -->
118135
[Hatch project]: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
119136
[Hatch project#link]: https://github.com/pypa/hatch
120137
[codecov]: https://codecov.io/gh/WSH032/fastapi-proxy-lib/graph/badge.svg?token=62QQU06E8X

docs/CHANGELOG/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--8<-- "CHANGELOG.md"

docs/CONTRIBUTING/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--8<-- "CONTRIBUTING.md"

docs/Usage/Security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ If you do not explicitly specify it, `ForwardHttpProxy` will issue a warning and
1414
- If you want to accept all proxy requests (**never do this on a public server**), you can do it like this:
1515

1616
```python
17-
proxy_filter = lambda _: None
17+
proxy_filter = lambda *_: None
1818
```
1919

2020
- If you want to implement your own proxy filter, please refer to the [fastapi_proxy_lib.core.tool.ProxyFilterProto][].
2121

22-
## `http` vs `https`
22+
## `http`/`ws` vs `https`/`wss`
2323

2424
!!! danger
2525
**Never use a server with the HTTPS protocol to proxy a target server (`base_url`) with the HTTP protocol !**

docs/images/rocket-24.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)