halfapi/README.md

83 lines
1.6 KiB
Markdown
Raw 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
2021-09-01 15:19:51 +02:00
It's an **ini** file that contains at least two sections, project and domains.
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
**name** : Project's name
2020-07-14 15:14:23 +02:00
2021-09-01 15:19:51 +02:00
**halfapi_version** : The HalfAPI version on which you work
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
2021-09-01 15:19:51 +02:00
The name of the options should be the name of the domains' module, the value is the
submodule which contains the routers.
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
Example :
2020-07-15 00:11:31 +02:00
2021-09-01 15:19:51 +02:00
dummy_domain = .routers
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.
```
python -m halfapi routes --export --noheader dummy_domain.routers | python -m halfapi run -
```
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