An example how to create API router module for LitePolis.
Project description
LitePolis-router Template
This repository serves as a template for creating router modules for LitePolis. It provides a basic structure and example code to guide you through the process.
:warning: Keep the prefix "litepolis-router-" and "litepolis_router_" in the name of package and directories to ensure the LitePolis package manager will be able to recognize it during deployment.
Getting Started
-
Clone the Repository: Start by cloning this repository to your local machine.
-
Rename the Package: Update the package name in the following files:
setup.py: Changename='litepolis-router-template'to your desired package name (e.g.,litepolis-router-dashboard). Also, update theversion,description,author, andurlfields accordingly.tests/test_core.py: Update the import statement to reflect your new package name. For example, changefrom litepolis_router_template import *tofrom litepolis_router_dashboard import *.- Rename the folder
litepolis_router_templateto your new package name.
-
Implement Database Logic: Modify the
litepolis_router_template/core.pyfile (renamed in the previous step) to interact with your specific database. Theinitfunction incore.pyis crucial for initializing the router and should be implemented correctly. TheDEFAULT_CONFIGdictionary incore.pyallows for configurable settings. Ensure you update the docstrings to accurately reflect the functionality of your endpoints. These docstrings will be used to generate API documentation. -
Testing: The
tests/test_core.pyfile contains example tests. Update these tests to cover your database module's functionality. Thetest_core.pyfile should utilize theDEFAULT_CONFIGandinitfunction to properly initialize the application for testing. Ensure the tests run successfully after making changes.
Key Files and Modifications
-
setup.py: This file contains metadata about your package. Crucially, you need to change thenamefield to your package's unique name. Also, update theversion,description,author, andurlfields as needed. -
litepolis_router_template/core.py: This file contains the core logic for your module, including theDEFAULT_CONFIGandinitfunction. Theinitfunction is essential for the LitePolis package manager to correctly initialize and start the services. TheDEFAULT_CONFIGdictionary provides default configuration settings. Replace the example endpoints with your own endpoints and operations. Important: Update the docstrings for API documentation generation. Pay attention to theResponseMessagemodel and adapt it if necessary to fit your data structures. -
tests/test_core.py: This file contains tests for your module. Update the tests to reflect your changes incore.py. Thorough testing is essential for ensuring the correctness of your module. Ensure your tests correctly utilize theinitfunction andDEFAULT_CONFIGfor proper setup.
Important Considerations
-
API Documentation: Well-documented code is crucial for maintainability and collaboration. Ensure your endpoints in
core.pyhave clear and comprehensive docstrings. These docstrings will be used to generate API documentation for LitePolis. For best practices and detailed examples, refer to this helpful resource: How to Document an API for Python FastAPI -
Testing: Write comprehensive tests to cover all aspects of your router module. This will help catch errors early and ensure the stability of your code.
-
Dependencies: If your module requires external libraries, add them to the
install_requireslist insetup.py. -
DEFAULT_CONFIGandinit: TheDEFAULT_CONFIGdictionary and theinitfunction are crucial for the package manager to correctly initialize and start the services. Ensure these are correctly implemented and used in your tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litepolis_router_example-0.0.1.tar.gz.
File metadata
- Download URL: litepolis_router_example-0.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22b9a89db4e025a374e15a5f623c8e890b4a495473b9661436f879a0daff29b2
|
|
| MD5 |
82df9c0ea72a6e40d6f7057d23d81fce
|
|
| BLAKE2b-256 |
98e2a0fb202c309397ef1c83d8070ff1b02d289e12fdee9c275ca06436d940a8
|
Provenance
The following attestation bundles were made for litepolis_router_example-0.0.1.tar.gz:
Publisher:
python-publish.yml on NewJerseyStyle/LitePolis-router-example
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litepolis_router_example-0.0.1.tar.gz -
Subject digest:
22b9a89db4e025a374e15a5f623c8e890b4a495473b9661436f879a0daff29b2 - Sigstore transparency entry: 189925754
- Sigstore integration time:
-
Permalink:
NewJerseyStyle/LitePolis-router-example@3fb1d04b9c946c22f5e9708573c6ebfd63a45284 -
Branch / Tag:
refs/tags/example - Owner: https://github.com/NewJerseyStyle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3fb1d04b9c946c22f5e9708573c6ebfd63a45284 -
Trigger Event:
release
-
Statement type:
File details
Details for the file litepolis_router_example-0.0.1-py3-none-any.whl.
File metadata
- Download URL: litepolis_router_example-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94044dcc0e785aefce2eaa4084c35a39252156b2104fadad224756b867f1f79
|
|
| MD5 |
c51fd20d5f5d6febfd5a81b810ab440f
|
|
| BLAKE2b-256 |
0735d9cd2dad58b109d0c7fa269528ee904e351279ad59e2938f9902c3bf8fb6
|
Provenance
The following attestation bundles were made for litepolis_router_example-0.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on NewJerseyStyle/LitePolis-router-example
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litepolis_router_example-0.0.1-py3-none-any.whl -
Subject digest:
a94044dcc0e785aefce2eaa4084c35a39252156b2104fadad224756b867f1f79 - Sigstore transparency entry: 189925756
- Sigstore integration time:
-
Permalink:
NewJerseyStyle/LitePolis-router-example@3fb1d04b9c946c22f5e9708573c6ebfd63a45284 -
Branch / Tag:
refs/tags/example - Owner: https://github.com/NewJerseyStyle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3fb1d04b9c946c22f5e9708573c6ebfd63a45284 -
Trigger Event:
release
-
Statement type: