Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit fd27d55

Browse files
committed
feat: init code
1 parent 4380a55 commit fd27d55

28 files changed

+2383
-1
lines changed

.chglog/CHANGELOG.tpl.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{ if .Versions -}}
2+
<a name="unreleased"></a>
3+
## [Unreleased]
4+
5+
{{ if .Unreleased.CommitGroups -}}
6+
{{ range .Unreleased.CommitGroups -}}
7+
### {{ .Title }}
8+
{{ range .Commits -}}
9+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
10+
{{ end }}
11+
{{ end -}}
12+
{{ end -}}
13+
{{ end -}}
14+
15+
{{ range .Versions }}
16+
<a name="{{ .Tag.Name }}"></a>
17+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
18+
{{ range .CommitGroups -}}
19+
### {{ .Title }}
20+
{{ range .Commits -}}
21+
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
22+
{{ end }}
23+
{{ end -}}
24+
25+
{{- if .RevertCommits -}}
26+
### Reverts
27+
{{ range .RevertCommits -}}
28+
- {{ .Revert.Header }}
29+
{{ end }}
30+
{{ end -}}
31+
32+
{{- if .MergeCommits -}}
33+
### Pull Requests
34+
{{ range .MergeCommits -}}
35+
- {{ .Header }}
36+
{{ end }}
37+
{{ end -}}
38+
39+
{{- if .NoteGroups -}}
40+
{{ range .NoteGroups -}}
41+
### {{ .Title }}
42+
{{ range .Notes }}
43+
{{ .Body }}
44+
{{ end }}
45+
{{ end -}}
46+
{{ end -}}
47+
{{ end -}}
48+
49+
{{- if .Versions }}
50+
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
51+
{{ range .Versions -}}
52+
{{ if .Tag.Previous -}}
53+
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
54+
{{ end -}}
55+
{{ end -}}
56+
{{ end -}}

.chglog/config.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/staticbackendhq/backend-python
6+
options:
7+
commits:
8+
filters:
9+
Type:
10+
- feat
11+
- fix
12+
- perf
13+
- refactor
14+
- doc
15+
- misc
16+
commit_groups:
17+
title_maps:
18+
feat: Features
19+
fix: Bug Fixes
20+
perf: Performance Improvements
21+
refactor: Code Refactoring
22+
doc: Documents
23+
misc: Misc
24+
header:
25+
pattern: "^(\\w*)\\:\\s(.*)$"
26+
pattern_maps:
27+
- Type
28+
- Subject
29+
notes:
30+
keywords:
31+
- BREAKING CHANGE

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 100

.github/workflows/lint.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
# We want to run on external PRs, but not on our own internal PRs as they'll be run
8+
# by the push to the branch. Without this if check, checks are duplicated since
9+
# internal PRs match both the push and pull_request events.
10+
if:
11+
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
12+
github.repository
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
22+
- name: Install poetry
23+
uses: snok/install-poetry@v1
24+
with:
25+
virtualenvs-create: true
26+
virtualenvs-in-project: true
27+
28+
- name: Load cached venv
29+
id: cached-poetry-dependencies
30+
uses: actions/cache@v2
31+
with:
32+
path: .venv
33+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
34+
35+
- name: Install dependencies
36+
run: poetry install
37+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
38+
39+
- name: Lint
40+
run: |
41+
poetry run black --check staticbackend
42+
poetry run flake8 staticbackend
43+
poetry run mypy staticbackend
44+
poetry run pylama staticbackend

.github/workflows/pypi.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: pypi
2+
on:
3+
release:
4+
types:
5+
- created
6+
jobs:
7+
build:
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
python-version: [ "3.6" ]
12+
os: [ ubuntu-latest ]
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
20+
- name: Install poetry
21+
uses: snok/install-poetry@v1
22+
with:
23+
virtualenvs-create: true
24+
virtualenvs-in-project: true
25+
26+
- name: Load cached venv
27+
id: cached-poetry-dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: .venv
31+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
32+
33+
- name: Install dependencies
34+
run: poetry install
35+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
36+
37+
- name: Build release
38+
run: poetry build
39+
40+
- uses: actions/upload-artifact@v2
41+
with:
42+
path: dist/
43+
44+
upload:
45+
runs-on: ubuntu-latest
46+
needs:
47+
- build
48+
steps:
49+
- uses: actions/download-artifact@v2
50+
with:
51+
name: artifact
52+
path: dist
53+
- uses: pypa/[email protected]
54+
with:
55+
user: __token__
56+
password: ${{ secrets.pypi_password }}

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ coverage.xml
5050
*.py,cover
5151
.hypothesis/
5252
.pytest_cache/
53+
cover/
5354

5455
# Translations
5556
*.mo
@@ -72,6 +73,7 @@ instance/
7273
docs/_build/
7374

7475
# PyBuilder
76+
.pybuilder/
7577
target/
7678

7779
# Jupyter Notebook
@@ -82,6 +84,8 @@ profile_default/
8284
ipython_config.py
8385

8486
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
8589
.python-version
8690

8791
# pipenv
@@ -127,3 +131,17 @@ dmypy.json
127131

128132
# Pyre type checker
129133
.pyre/
134+
135+
# pytype static type analyzer
136+
.pytype/
137+
138+
# Cython debug symbols
139+
cython_debug/
140+
141+
# Editor-related
142+
.vscode/
143+
.idea/
144+
.pydevproject
145+
146+
# Taskfile
147+
Taskfile.yml

.pre-commit-config.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-docstring-first
8+
9+
- repo: https://github.com/pycqa/flake8
10+
rev: "3.9.2" # pick a git hash / tag to point to
11+
hooks:
12+
- id: flake8
13+
exclude: ^tests/
14+
15+
- repo: https://github.com/pre-commit/mirrors-mypy
16+
rev: v0.910
17+
hooks:
18+
- id: mypy
19+
additional_dependencies: [types-all]
20+
exclude: ^tests/
21+
22+
- repo: https://github.com/asottile/pyupgrade
23+
rev: v2.25.0
24+
hooks:
25+
- id: pyupgrade

.prettierrc.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
proseWrap: always
2+
printWidth: 88
3+
endOfLine: auto

README.md

+59-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,60 @@
11
# backend-python
2-
StaticBackend Python client
2+
3+
[StaticBackend](https://staticbackend.com/) Python 3 client.
4+
5+
## Requirements
6+
7+
CPython 3.6.2+
8+
9+
## Installatin
10+
11+
```
12+
pip install staticbackend
13+
```
14+
15+
## Usage
16+
17+
```python
18+
from staticbackend import Config, StaticBackend
19+
20+
config = Config(
21+
api_token=os.environ["PUBLICKEY"],
22+
root_token=os.environ["ROOTKEY"],
23+
endpoint=os.environ["ENDPOINT"],
24+
)
25+
backend = StaticBackend(config)
26+
state = backend.user.login("[email protected]", "zot")
27+
docs = state.database.list_documents(db)
28+
print(docs)
29+
```
30+
31+
## Features
32+
33+
- [x] User Management
34+
- [x] Register
35+
- [x] Login
36+
- [x] Reset Password
37+
- [x] Database
38+
- [x] Create a document
39+
- [x] List documents
40+
- [x] Get a document
41+
- [x] Query for documents
42+
- [x] Update a document
43+
- [x] Delete documents
44+
- [x] Storage
45+
- [x] Upload files
46+
- [ ] Forms
47+
- [ ] Submit HTML forms
48+
- [ ] Websocket
49+
50+
## License
51+
52+
MIT
53+
54+
## Contributing
55+
56+
TBD.
57+
58+
## CHANGELOG
59+
60+
See [CHANGELOG.md](https://github.com/staticbackendhq/backend-python/blob/main/CHANGELOG.md)

docs/index.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Welcome to StaticBackend Python Client
2+
3+
## Install
4+
5+
```
6+
pip install staticbackend
7+
```
8+
9+
## Usage
10+
11+
```python
12+
from staticbackend import Config, StaticBackend
13+
14+
config = Config(
15+
api_token=os.environ["PUBLICKEY"],
16+
root_token=os.environ["ROOTKEY"],
17+
endpoint=os.environ["ENDPOINT"],
18+
)
19+
backend = StaticBackend(config)
20+
state = backend.user.login("[email protected]", "zot")
21+
docs = state.database.list_documents(db)
22+
print(docs)
23+
```
24+
25+
## Features
26+
27+
- [x] User Management
28+
- [x] Register
29+
- [x] Login
30+
- [x] Reset Password
31+
- [x] Database
32+
- [x] Create a document
33+
- [x] List documents
34+
- [x] Get a document
35+
- [x] Query for documents
36+
- [x] Update a document
37+
- [x] Delete documents
38+
- [x] Storage
39+
- [x] Upload files
40+
- [ ] Forms
41+
- [ ] Submit HTML forms
42+
- [ ] Websocket
43+
44+
## License
45+
46+
MIT
47+
48+
## Contributing
49+
50+
TBD.
51+
52+
## CHANGELOG
53+
54+
See [CHANGELOG.md](https://github.com/staticbackendhq/backend-python/blob/main/CHANGELOG.md)

0 commit comments

Comments
 (0)