halfapi/README.md

105 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2020-07-14 15:14:23 +02:00
# HalfAPI
Base tools to develop complex API with rights management.
This project was developped by Maxime Alves and Joël Maïzi. The name was chosen
to reference [HalfORM](https://github.com/collorg/halfORM), a project written by Joël Maïzi.
2020-07-14 15:14:23 +02:00
## Dependencies
- python3
- python3-pip
2020-07-29 21:25:12 +02:00
- libgit2-dev
2021-09-01 15:19:51 +02:00
- starlette
- PyJWT
- click
- uvicorn
- orjson
- pyyaml
2020-07-14 15:14:23 +02:00
2021-09-01 15:19:51 +02:00
## Configuration
2020-07-14 15:14:23 +02:00
2021-09-01 15:19:51 +02:00
Configure HalfAPI in the file : .halfapi/config .
2020-07-14 15:14:23 +02:00
2023-02-03 12:43:30 +01:00
It's a **toml** file that contains at least two sections, project and domains.
https://toml.io/en/
2020-07-14 15:14:23 +02:00
2021-09-01 15:24:53 +02:00
2021-09-01 15:19:51 +02:00
### Project
2021-09-01 15:19:51 +02:00
The main configuration options without which HalfAPI cannot be run.
2020-07-14 15:14:23 +02:00
2021-09-01 15:19:51 +02:00
**secret** : The file containing the secret to decode the user's tokens.
2021-09-01 15:19:51 +02:00
**port** : The port for the test server.
2021-09-01 15:19:51 +02:00
**loglevel** : The log level (info, debug, critical, ...)
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
### Domains
2020-07-15 00:11:31 +02:00
2023-02-03 12:43:30 +01:00
Specify the domains configurations in the following form :
2020-07-15 00:11:31 +02:00
2023-02-03 12:43:30 +01:00
```
[domains.DOMAIN_NAME]
name = "DOMAIN_NAME"
enabled = true
prefix = "/prefix"
module = "domain_name.path.to.api.root"
port = 1002
```
2020-07-15 00:11:31 +02:00
2023-02-03 12:43:30 +01:00
Specific configuration can be done under the "config" section :
```
[domains.DOMAIN_NAME.config]
boolean_option = false
string_value = "String"
answer = 42
listylist = ["hello", "world"]
```
And can be accessed through the app's "config" dictionnary.
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
## Usage
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
Develop an HalfAPI domain by following the examples located in
tests/dummy_domain . An HalfAPI domain should be an importable python module
that is available in the python path.
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
Run the project by using the `halfapi run` command.
2020-07-15 00:11:31 +02:00
You can try the dummy_domain with the following command.
```
2023-02-03 12:43:30 +01:00
PYTHONPATH=$PWD/tests python -m halfapi domain dummy_domain
```
2023-02-03 12:43:30 +01:00
### CLI documentation
Use the CLI help.
```
python -m halfapi --help
python -m halfapi domain --help
```
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
## API Testing
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
@TODO
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
### Example
2020-07-29 21:25:12 +02:00
2021-09-01 15:19:51 +02:00
Check out the [sample project](https://github.com/halfAPI/halfapi_sample_project)
that helps you to build your own domain.
2020-07-29 21:25:12 +02:00
2021-09-01 15:19:51 +02:00
## Development
2020-07-29 21:25:12 +02:00
2021-09-01 15:19:51 +02:00
@TODO