Package: apistar-autoapp
API Star AutoAppEasily manage and compose API Star projectsAutomatically orchestratesAPI Starprojects with sub modules using anappbased pattern.FeaturesQuickstartInstallAnatomyExample project structureDocsAutoAppAutoASyncAppapp_argsPrint HelperincluderouteroutescomponentsTODOFeaturesAutomatically build URLs based on your project's structure.AutoappIncludes routesfrom apps in your project creating the appropriate URL based on the
filesystem path from the projects rootapp.pyfile.Automatically collectevent_hooksandcomponentlists from apps and consolidate them
together to build theApp/ASyncAppwith.Easily add external packages that support theapp.pylayout.ex:AutoApp(apps=['apistar_websocket'])Allow an ordered priority list of apps by their path string to control the order of items
in theevent_hooksandcomponentlists as well as control import order.QuickstartJust useAutoApporAutoASyncAppin place ofAppandASyncApprespectivelyfromapistar-autoappimportAutoAppasyncdefwelcome()->dict:return{'msg':'hello'}routes=[Route('/','GET',handler=welcome,name='welcome'),]app=AutoApp(routes=routes,)if__name__=='__main__':app.serve('127.0.0.1',8000,debug=True)An ASync application that uses theapistar-websocketpackage. To use the external library simply
list it in theappsparameter.NOTE: packages listed inappsmust support theapp.pylayout.fromapistar-autoappimportAutoASyncAppasyncdefwelcome()->dict:return{'msg':'hello'}routes=[Route('/','GET',handler=welcome,name='welcome'),]app=AutoASyncApp(apps=['apistar_websocket'],routes=routes,)if__name__=='__main__':app.serve('127.0.0.1',8000,debug=True)Installpip install apistar-autoappor forPipenvuserspipenv install apistar-autoappAnatomyFor a package to be considered an 'app' it must contain a file namedapp.pyin it's top directory. Theapp.pyfile can be empty. It's in theapp.pyfile where you expose what your app
provides to theAPI Starconfiguration. Autoapp will look
for three attributes on theapp.pymodule and if they're found add them to theAPI Starconfiguration at startup.The attributes must be lists and named:routes
components
event_hooksFor example, a simple app that only exposes it's routes could be:app.py:from .handlers import routesOr an app that exposes it's routes, event_hooks and components:app.py:from .handlers import routes
from .components import components
from .event_hooks import event_hooksAnd of course if you have a simple app you can have all of your code in theapp.pyand
then have module variables defined by your application code.A simple app:fromapistarimportApp,Routedefhomepage()->str:return'<html><body><h1>Homepage</h1></body></html>'routes=[Route('/',method='GET',handler=homepage),]Example project structureproject/
  app.py
  v1/
    app.py
    ...
    endpointOne/
      app.py
      ...
    endpointTwo/
      app.py
      ...If thev1/app.pyfile is empty and each of theendpoint*apps exposes a single root URL,/, route the
route URLs created for the project, viaIncludeswould be:/v1/endpointOne
/v1/endpointTwoAnd ifendpointOnehad another route for the URL/users, you'd then have:/v1/endpointOne
/v1/endpointOne/users
/v1/endpointTwoDocsAutoAppAutoApp(project_dir: str = None,
        priority_apps: list = None,
        print_results: bool = False,
        **kwargs) -> AppParameters:(Optional)
apps: A list of packages to add to your App. Use this for packages outside or your App/project.
Packages listed in the apps list must be on your PYTHON_PATH.

(Optional)
project_dir: The directory from which apistar-autoapp will look for a project root.
    This is autodetected if not used and you normally won't use this parameter.

(Optional)
priority_apps: A list of apps, by their import path, that will be imported before all
  other apps found by apistar-autoapp and imported in the order they are given.

(Optional)
print_results: Print the results of the configuration created by apistar-autoapp to
  the console.

kwargs: These are the arguments you'd normally pass to App or ASyncApp. If you pass
  any of the arguments: routes, components or event_hooks, they will be given precedence
  and listed before any of the corresponding values created by autoapp.AutoASyncAppThe same asAutoAppbut creates a project usingASyncAppAutoASyncApp(project_dir: str = None,
             priority_apps: list = None,
             print_results: bool = False,
             **kwargs) -> ASyncAppapp_argsapp_args(project_dir: str = None,
         priority_apps: list = None,
         print_results: bool = False,
         **kwargs) -> dict:app_argsis the same as AutoApp and AutoASyncApp except it returns a dictionary of arguments
that are intended for use byApporASyncApp.In factAutoAppis just:defAutoApp(**kwargs)->App:returnApp(**app_args(**kwargs))So if you want to do something with the data from autoapp before creating your App it's easy:kwargs=app_args(...)# Do something with kwargs# ...app=App(**kwargs)Print helperThere are some printing helpers for internal use by apistar-autoapp but are exposed for use by other
modules. There is aPrinterclass the usesprintby default but can use any function that
accepts a string in it's place.fromapistar_autoapp.printerimportPrinterpr=Printer()# Or if you want to your own print function, like a logger:pr=Printer(printer=logger.info)...# to print out a list of routes:pr.routes(routes)includePrints anIncludeinstance to the console as well as all of it'sRoutesin the form:Include: <url> <name>
    <Routes>ex:Include: /v2/welcome v2:welcome
Route: GET /, welcome
app.welcome() -> dict:routePrints aRouteinstance to the console in the form:Route: <method> <url>, <name>
       <handler>ex:Route: GET /, welcome
       app.welcome() -> dict:routesPrints a list ofRoutesandIncludesusingprint_routeandprint_includein the form:Routes:
    [
        <print_route> or <print_include>,
        ...
    ]ex:Routes:
    Route: GET /, welcome
           app.welcome() -> dict:
    Include: /v2/home v2:home
      Route: GET /v2/home/, list
             v2.home.handlers.list_homes() -> list:
    ...componentsPrints a list ofcomponentsin the form:Components:
        <ComponentClass>
                resolve(<signature>) -> <returns>:ex:Components:
        WebSocketComponent
                resolve(self, scope: ASGIScope, send: ASGISend, receive: ASGIReceive, app: App) -> WebSocket:TODOAllow any package with anapp.pyfile that is importable to be used with AutoappAdd the ability to have a list of excluded apps that will not be imported by AutoappAdd printer forevent_hooks