Skip to main content

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

  1. Clone the Repository: Start by cloning this repository to your local machine.

  2. Rename the Package: Update the package name in the following files:

    • setup.py: Change name='litepolis-router-template' to your desired package name (e.g., litepolis-router-dashboard). Also, update the version, description, author, and url fields accordingly.
    • tests/test_core.py: Update the import statement to reflect your new package name. For example, change from litepolis_router_template import * to from litepolis_router_dashboard import *.
    • Rename the folder litepolis_router_template to your new package name.
  3. Implement Database Logic: Modify the litepolis_router_template/core.py file (renamed in the previous step) to interact with your specific database. The init function in core.py is crucial for initializing the router and should be implemented correctly. The DEFAULT_CONFIG dictionary in core.py allows 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.

  4. Testing: The tests/test_core.py file contains example tests. Update these tests to cover your database module's functionality. The test_core.py file should utilize the DEFAULT_CONFIG and init function 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 the name field to your package's unique name. Also, update the version, description, author, and url fields as needed.

  • litepolis_router_template/core.py: This file contains the core logic for your module, including the DEFAULT_CONFIG and init function. The init function is essential for the LitePolis package manager to correctly initialize and start the services. The DEFAULT_CONFIG dictionary 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 the ResponseMessage model 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 in core.py. Thorough testing is essential for ensuring the correctness of your module. Ensure your tests correctly utilize the init function and DEFAULT_CONFIG for proper setup.

Important Considerations

  • API Documentation: Well-documented code is crucial for maintainability and collaboration. Ensure your endpoints in core.py have 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_requires list in setup.py.

  • DEFAULT_CONFIG and init: The DEFAULT_CONFIG dictionary and the init function 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litepolis_router_example-0.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litepolis_router_example-0.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

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

Hashes for litepolis_router_example-0.0.1.tar.gz
Algorithm Hash digest
SHA256 22b9a89db4e025a374e15a5f623c8e890b4a495473b9661436f879a0daff29b2
MD5 82df9c0ea72a6e40d6f7057d23d81fce
BLAKE2b-256 98e2a0fb202c309397ef1c83d8070ff1b02d289e12fdee9c275ca06436d940a8

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file litepolis_router_example-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for litepolis_router_example-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a94044dcc0e785aefce2eaa4084c35a39252156b2104fadad224756b867f1f79
MD5 c51fd20d5f5d6febfd5a81b810ab440f
BLAKE2b-256 0735d9cd2dad58b109d0c7fa269528ee904e351279ad59e2938f9902c3bf8fb6

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page