Coder Social home page Coder Social logo

litestar-org / litestar-fullstack Goto Github PK

View Code? Open in Web Editor NEW
283.0 17.0 47.0 12.56 MB

Litestar Fullstack Reference Application with React, Vite, SQLAlchemy, Docker, Task Queues, and more!

Home Page: https://fullstack.litestar.dev/

License: MIT License

Dockerfile 2.16% Makefile 2.01% Python 56.94% Mako 0.52% TypeScript 36.65% CSS 0.40% Jinja 0.11% Shell 0.05% JavaScript 1.15%
litestar litestar-api litestar-framework litestar-template starlite starlite-api starlite-framework starlite-template vite sqlalchemy

litestar-fullstack's Introduction

Litestar Logo - Light Litestar Logo - Dark

Project Status
CI/CD Tests and Linting Documentation Building
Quality Coverage Quality Gate Status Maintainability Rating Reliability Rating Security Rating
Community Reddit Discord Matrix Medium Twitter Blog
Meta Litestar Project types - Mypy License - MIT Litestar Sponsors linting - Ruff code style - Black All Contributors

Litestar Fullstack Reference Application

This is a reference application that you can use to get your next Litestar application running quickly.

It contains most of the boilerplate required for a production web API with features like:

  • Latest Litestar configured with best practices
  • Integration with SQLAlchemy 2.0, SAQ (Simple Asynchronous Queue), Structlog, and Granian
  • Extends built-in Litestar click CLI
  • Frontend integrated with Vite and includes Jinja2 templates that integrate with Vite websocket/HMR support
  • Multi-stage Docker build using a minimal Python 3.12 runtime image.
    • Optional Multi-stage Distroless Docker build.
  • Pre-configured user model that includes teams and associated team roles
  • Examples of using guards for superuser and team-based auth.
  • Examples using raw SQL for more complex queries

Take what you need and adapt it to your own projects

Quick Start

To quickly get a development environment running, run the following:

make install
. .venv/bin/activate

Local Development

cp .env.local.example .env
pdm run start-infra # this starts a database and redis instance only
# this will start the SAQ worker, Vite development process, and Litestar
pdm run app run

# to stop the database and redis, run
pdm run stop-infra

Docker

docker compose up

Details

We have documented the process to help you get the repository up and running. Check out the documentation for more information.

Command Examples

App Commands

❯ app

 Usage: app [OPTIONS] COMMAND [ARGS]...

 Litestar CLI.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --app          TEXT       Module path to a Litestar application (TEXT)       │
│ --app-dir      DIRECTORY  Look for APP in the specified directory, by adding │
│                           this to the PYTHONPATH. Defaults to the current    │
│                           working directory.                                 │
│                           (DIRECTORY)                                        │
│ --help     -h             Show this message and exit.                        │
╰──────────────────────────────────────────────────────────────────────────────╯
Using Litestar app from env: 'app.asgi:app'
Loading environment configuration from .env
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ assets       Manage Vite Tasks.                                              │
│ database     Manage SQLAlchemy database components.                          │
│ info         Show information about the detected Litestar app.               │
│ routes       Display information about the application's routes.             │
│ run          Run a Litestar app.                                             │
│ schema       Manage server-side OpenAPI schemas.                             │
│ sessions     Manage server-side sessions.                                    │
│ users        Manage application users and roles.                             │
│ version      Show the currently installed Litestar version.                  │
│ workers      Manage background task workers.                                 │
╰──────────────────────────────────────────────────────────────────────────────╯

Database Commands

Alembic integration is built directly into the CLI under the database command.

❯ app database
Using Litestar app from env: 'app.asgi:create_app'

 Usage: app database [OPTIONS] COMMAND [ARGS]...

 Manage SQLAlchemy database components.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --help  -h    Show this message and exit.                                    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ downgrade              Downgrade database to a specific revision.            │
│ init                   Initialize migrations for the project.                │
│ make-migrations        Create a new migration revision.                      │
│ merge-migrations       Merge multiple revisions into a single new revision.  │
│ show-current-revision  Shows the current revision for the database.          │
│ stamp-migration        Mark (Stamp) a specific revision as current without   │
│                        applying the migrations.                              │
│ upgrade                Upgrade database to a specific revision.              │
╰──────────────────────────────────────────────────────────────────────────────╯

Upgrading the Database

❯ app database upgrade
Using Litestar app from env: 'app.asgi:create_app'
Starting database upgrade process ───────────────────────────────────────────────
Are you sure you you want migrate the database to the "head" revision? [y/n]: y
2023-10-01T19:44:13.536101Z [debug    ] Using selector: EpollSelector
2023-10-01T19:44:13.623437Z [info     ] Context impl PostgresqlImpl.
2023-10-01T19:44:13.623617Z [info     ] Will assume transactional DDL.
2023-10-01T19:44:13.667920Z [info     ] Running upgrade  -> c3a9a11cc35d, init
2023-10-01T19:44:13.774932Z [debug    ] new branch insert c3a9a11cc35d
2023-10-01T19:44:13.783804Z [info     ] Pool disposed. Pool size: 5  Connections
 in pool: 0 Current Overflow: -5 Current Checked out connections: 0
2023-10-01T19:44:13.784013Z [info     ] Pool recreating

Worker Commands

❯ app worker
Using Litestar app from env: 'app.asgi:create_app'

 Usage: app worker [OPTIONS] COMMAND [ARGS]...

 Manage application background workers.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --help  -h    Show this message and exit.                                    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ run       Starts the background workers.                                     │
╰──────────────────────────────────────────────────────────────────────────────╯

Run Commands

To run the application through Granian (HTTP1 or HTTP2) using the standard Litestar CLI, you can use the following:

❯ app run --help
Using Litestar app from env: 'app.asgi:app'
Loading environment configuration from .env

 Usage: app run [OPTIONS]

 Run a Litestar app.
 The app can be either passed as a module path in the form of <module
 name>.<submodule>:<app instance or factory>, set as an environment variable
 LITESTAR_APP with the same format or automatically discovered from one of
 these canonical paths: app.py, asgi.py, application.py or app/__init__.py.
 When auto-discovering application factories, functions with the name
 ``create_app`` are considered, or functions that are annotated as returning a
 ``Litestar`` instance.

╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --port                   -p  INTEGER                 Serve under this port   │
│                                                      (INTEGER)               │
│                                                      [default: 8000]         │
│ --wc,--web-concurrency…  -W  INTEGER RANGE           The number of processes │
│                              [1<=x<=7]               to start.               │
│                                                      (INTEGER RANGE)         │
│                                                      [default: 1; 1<=x<=7]   │
│ --threads                    INTEGER RANGE [x>=1]    The number of threads.  │
│                                                      (INTEGER RANGE)         │
│                                                      [default: 1; x>=1]      │
│ --blocking-threads           INTEGER RANGE [x>=1]    The number of blocking  │
│                                                      threads.                │
│                                                      (INTEGER RANGE)         │
│                                                      [default: 1; x>=1]      │
│ --threading-mode             THREADMODES             Threading mode to use.  │
│                                                      (THREADMODES)           │
│ --http                       HTTPMODES               HTTP Version to use     │
│                                                      (HTTP or HTTP2)         │
│                                                      (HTTPMODES)             │
│ --opt                                                Enable additional event │
│                                                      loop optimizations      │
│ --backlog                    INTEGER RANGE [x>=128]  Maximum number of       │
│                                                      connections to hold in  │
│                                                      backlog.                │
│                                                      (INTEGER RANGE)         │
│                                                      [default: 1024; x>=128] │
│ --host                   -H  TEXT                    Server under this host  │
│                                                      (TEXT)                  │
│                                                      [default: 127.0.0.1]    │
│ --ssl-keyfile                FILE                    SSL key file (FILE)     │
│ --ssl-certificate            FILE                    SSL certificate file    │
│                                                      (FILE)                  │
│ --create-self-signed-c…                              If certificate and key  │
│                                                      are not found at        │
│                                                      specified locations,    │
│                                                      create a self-signed    │
│                                                      certificate and a key   │
│ --http1-buffer-size          INTEGER RANGE           Set the maximum buffer  │
│                              [x>=8192]               size for HTTP/1         │
│                                                      connections             │
│                                                      (INTEGER RANGE)         │
│                                                      [default: 417792;       │
│                                                      x>=8192]                │
│ --http1-keep-alive/--n…                              Enables or disables     │
│                                                      HTTP/1 keep-alive       │
│                                                      [default:               │
│                                                      http1-keep-alive]       │
│ --http1-pipeline-flush…                              Aggregates HTTP/1       │
│                                                      flushes to better       │
│                                                      support pipelined       │
│                                                      responses               │
│                                                      (experimental)          │
│ --http2-adaptive-windo…                              Sets whether to use an  │
│                                                      adaptive flow control   │
│                                                      for HTTP2               │
│ --http2-initial-connec…      INTEGER                 Sets the max            │
│                                                      connection-level flow   │
│                                                      control for HTTP2       │
│                                                      (INTEGER)               │
│ --http2-initial-stream…      INTEGER                 Sets the                │
│                                                      `SETTINGS_INITIAL_WIND… │
│                                                      option for HTTP2        │
│                                                      stream-level flow       │
│                                                      control                 │
│                                                      (INTEGER)               │
│ --http2-keep-alive-int…      OPTIONAL                Sets an interval for
│                                                      HTTP2 Ping frames       │
│                                                      should be sent to keep  │
│                                                      a connection alive      │
│                                                      (OPTIONAL)              │
│ --http2-keep-alive-tim…      INTEGER                 Sets a timeout for
│                                                      receiving an            │
│                                                      acknowledgement of the  │
│                                                      HTTP2 keep-alive ping   │
│                                                      (INTEGER)               │
│ --http2-max-concurrent…      INTEGER                 Sets the                │
│                                                      SETTINGS_MAX_CONCURREN… │
│                                                      option for HTTP2        │
│                                                      connections             │
│                                                      (INTEGER)               │
│ --http2-max-frame-size       INTEGER                 Sets the maximum frame  │
│                                                      size to use for HTTP2   │
│                                                      (INTEGER)               │
│ --http2-max-headers-si…      INTEGER                 Sets the max size of    │
│                                                      received header frames  │
│                                                      (INTEGER)               │
│ --http2-max-send-buffe…      INTEGER                 Set the maximum write   │
│                                                      buffer size for each    │
│                                                      HTTP/2 stream           │
│                                                      (INTEGER)               │
│ --url-path-prefix            TEXT                    URL path prefix the app │
│                                                      is mounted on           │
│                                                      (TEXT)                  │
│ --debug                  -d                          Run app in debug mode   │
│ --pdb,--use-pdb          -P                          Drop into PDB on an     │
│                                                      exception               │
│ --respawn-failed-worke…                              Enable workers respawn  │
│                                                      on unexpected exit
│ --reload                 -r                          Reload server on        │
│                                                      changes                 │
│ --help                   -h                          Show this message and   │
│                                                      exit.                   │
╰──────────────────────────────────────────────────────────────────────────────╯

litestar-fullstack's People

Contributors

3phedra avatar alc-alc avatar aorith avatar bpereto avatar brody192 avatar cemremengu avatar ch-iv avatar cofin avatar darinkishore avatar dependabot[bot] avatar faolain avatar franzforstmayr avatar goldziher avatar jacobcoffee avatar mvsrgc avatar odiseo0 avatar patrickarmengol avatar peterschutt avatar rosstitmarsh avatar sorasful avatar thegreatalgo avatar tobi-de avatar tomviner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

litestar-fullstack's Issues

Enhancement: Add HTML email template examples

Summary

Add examples of sending templated emails.

  • This is probably a good place to show examples of events/emitters

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Bug: CLI command "database" seems to be missing

Description

since 6bf83ba the cli command app database seems to be missing.

Re-adding the database management commands seems to missing some information? I don't know the new Alembic integration and did not understand the mechanics in a brief overview:

  File "src/app/lib/db/migrations/env.py", line 115, in run_migrations_online
    configuration["sqlalchemy.url"] = config.db_url
                                      ^^^^^^^^^^^^^
AttributeError: 'Config' object has no attribute 'db_url'

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"In the format of: ![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

2.2.1

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Enhancement: Additional Integration Tests

Summary

All endpoints should have integration tests for validating functionality.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Bug: default behaviour change in CollectionFilter breaks id filter

Description

the change of the default behaviour of CollectionFilter in litestar-org/advanced-alchemy#51 breaks the current implementation of provide_id_filter

def provide_id_filter(

Currently, there is an empty list if no id's are provided in the field_name id.
By default, I don't want the ID filter to apply and get all results.

Would it be needed to check if a query value for "ids" is provided and only then returning a CollectionFilter instance?

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

"In the format of: ![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

No response

Litestar Version

litestar==2.2.1
advanced-alchemy==0.3.2

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Enhancement: Move SAQ integration to plugin

Summary

Refactor the current SAQ integration so that it uses a litestar plugin. This could then be move to litestar.contrib

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Enhancement: Align build and testing process with `litestar-org`

Summary

This project has been a test area for things and has not always adhered to the same test config, build setup, etc of other repositories.

This should cleaned up and aligned with the other projects.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Enhancement: Extend example to use object storage

Summary

The example could optionally be extended to show how to deploy an app when using object storage such as Google Cloud Storage or S3.

minio could be added to the Dockerfile for local s3 support.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Bug: Fix Railway Deploy

Description

Get the Railway deploy up and working

URL to code causing the issue

https://railway.app/project/6f1f252f-a6f4-42ab-a5c7-6ba05c3f74de/service/944db6ab-1591-48f8-84f3-203c66e234e1?id=492a5cfa-7abf-415b-870d-d17a82989a45

MCVE

No response

Steps to reproduce

No response

Screenshots

No response

Logs

engine = create_async_engine(
^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/engine.py", line 117, in create_async_engine
sync_engine = _create_engine(url, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 2, in create_engine
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
return fn(*args, **kwargs)  # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 601, in create_engine
dbapi = dbapi_meth(**dbapi_args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 690, in import_dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'


### Package Version

Current

### Platform

- [X] Linux
- [ ] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)

Bug: schema typescript command failing

Description

On clear pull of the repo and after running make install. Trying to run app schema typescript results in an error
The error displayed do not give me enough information to find the root issue

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Pull main branch
2. Install using `make install`
3. Activate venv
4. Run `app schema typescript` command
5. See error

Screenshots

"In the format of: ![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

Traceback (most recent call last):
  File "/project/litestar-fullstack/.venv/bin/app", line 8, in <module>
    sys.exit(run_cli())
             ^^^^^^^^^
  File "/project/litestar-fullstack/src/app/__main__.py", line 23, in run_cli
    run_litestar_cli()
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/__main__.py", line 6, in run_cli
    litestar_group()
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/cli/_utils.py", line 280, in wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/cli/_utils.py", line 280, in wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/cli/commands/schema.py", line 81, in generate_typescript_specs
    specs = convert_openapi_to_typescript(app.openapi_schema, namespace)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/_openapi/typescript_converter/converter.py", line 291, in convert_openapi_to_typescript
    parse_request_body(
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/_openapi/typescript_converter/converter.py", line 205, in parse_request_body
    parse_schema(schema) if body.required else TypeScriptUnion((parse_schema(schema), undefined)),
    ^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/_openapi/typescript_converter/schema_parsing.py", line 152, in parse_schema
    return parse_type_schema(schema=schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/project/litestar-fullstack/.venv/lib/python3.12/site-packages/litestar/_openapi/typescript_converter/schema_parsing.py", line 129, in parse_type_schema
    raise TypeError(f"received an unexpected openapi type: {schema.type}")  # pragma: no cover
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: received an unexpected openapi type: None

Package Version

Main branch of litestar-fullstack

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Bug: CLI doesn't work

Description

app command doesn't work:

ModuleNotFoundError: No module named 'app.cli'; 'app' is not a package

URL to code causing the issue

No response

MCVE

poetry install
app

Steps to reproduce

No response

Screenshots

No response

Logs

No response

Litestar Version

2.0.0 9e67d91 (from poetry.lock)

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Enhancement: Implement a `collectstatic` command

Summary

Django offers a very nice collectstatic command to help manage static assets within the application. Combined with django-storages, the command will push static files to object storage.

Litestar does not need the file centralization that collectstatic does, but it would be great if it could push static files to object storage in production. This would definitely make production deployments that include static assets easier to manage.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Bug: default "camel" rename_strategy in DTO causes issues

Description

The default "camel" rename_strategy assigned in dto.py breaks routes in which there are camelCase parameters.

MCVE

DTOs:

@dataclass
class PasswordUpdate:
    old_password: str
    new_password: str

class PasswordUpdateDTO(DataclassDTO[PasswordUpdate]):
    config = dto.config()

Endpoint:

    @patch(
        operation_id="UpdatePasswordUser",
        name="users:update_password",
        path=urls.USER_PASSWORD_UPDATE,
        dto=PasswordUpdateDTO,
        return_dto=None,
    )
    async def update_users_password(
        self, data: DTOData[PasswordUpdate], users_service: UserService, current_user: User
    ) -> None:
        """Update the currently logged user password."""
        current_password = data._data_as_builtins["old_password"]
        new_password = data._data_as_builtins["new_password"]
        await users_service.update_password(current_password, new_password, current_user)

Test:

    # This will return 400 as the incoming data is expected to be in camelCase and validation will fail.
    response = await client.patch(
        "/api/me/update-password",
        json={"old_password": "old-password", "new_password": "new-password"},
    )

    # This passes validation, but it will return 500 as data._data_as_builtins is an empty dictionary
    response = await client.patch(
        "/api/me/update-password",
        json={"oldPassword": "old-password", "newPassword": "new-password"},
    )

Temporary fix

I ended up removing the default rename_strategy from dto.py and stick to camel_case in and out. I think that this is the behavior devs expect (less magic, more happiness) and works out of the box.

image

Litestar Version

In 2.0.0b4 gave some problems, but it worked (hence the workaround data._data_as_builtins["xx"] instead of xx = data.create_instance(), as the latter didn't work)

2.0.0rc1 broke it completely

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Alembic is not correctly configured

It seems that whenever one tries to generate new migrations, Alembic does not see the models and drops the tables (or returns an empty migration file if generating the initial migration).

Steps to reproduce

  1. Clone repo
  2. make install
  3. poetry install
  4. poetry run app database create-database
  5. make migrations

At this point, Alembic should see no changes, thus create an empty migration file. Instead, it creates a migration file in which all tables are dropped.

Logs:

make migrations
ATTENTION: This operation will create a new database migration for any defined models changes.
Migration message: whatevs
2023-08-08T15:48:05.052365Z [info     ] Context impl PostgresqlImpl.
2023-08-08T15:48:05.052742Z [info     ] Will assume transactional DDL.
2023-08-08T15:48:07.309490Z [info     ] Detected removed index 'ix_team_invitation_email' on 'team_invitation'
2023-08-08T15:48:07.310093Z [info     ] Detected removed table 'team_invitation'
2023-08-08T15:48:07.749287Z [info     ] Detected removed index 'ix_team_member_role' on 'team_member'
2023-08-08T15:48:07.749680Z [info     ] Detected removed table 'team_member'
2023-08-08T15:48:08.608711Z [info     ] Detected removed table 'team_tag'
2023-08-08T15:48:08.738695Z [info     ] Detected removed table 'user_account'
2023-08-08T15:48:08.865892Z [info     ] Detected removed table 'tag'
2023-08-08T15:48:08.995045Z [info     ] Detected removed index 'ix_team_name' on 'team'
2023-08-08T15:48:08.995544Z [info     ] Detected removed index 'ix_team_slug' on 'team'
2023-08-08T15:48:08.995788Z [info     ] Detected removed table 'team'
  Generating /home/x/projects/litestar-fullstack/src/app/lib/db/migrations/versions/2023-08-08_whatevs_cdd6bd1ce53b.py
  ...  done

Possible Enhancement: taskiq integration

Summary

Since it's a fullstack app template, I was wondering maybe integration with taskiq would be a good idea.

We have litestar integration so it should be easy to integrate. It's a common demand of web-apps for delayed or heavy to compute functions that should be executed somewhere aside from the web server.

What do you think? If you agree, I'll make a PR with it.

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

Docs: Better explanations of how things work

Hi, I'm looking for a cross of Diango and FastAPI (read "Django building experience but lean and with first class pydantic and openapi support). Litestar and this repo in particular look like a great start but as somebody spoiled by Dingo abstracting away a lot of the backend, I'm wondering whether there can be a simple guide for how to use this repo coming from Django without having to learn all about SQLAlchemy etc. Or maybe you'd recommend a different stack? I assume many people looking to migrate from django to litestar will aim to do so via this repo.

Thanks


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh Litestar dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar

Errors when running tests

On a fresh clone of the repo some of the integration tests in test_accounts.py and test_teams.py raise

socket.gaierror: [Errno -3] Temporary failure in name resolution

Been poking at it for a while and can't quite figure out what is going on

Usage of `@lru_cache` in settings

https://github.com/cofin/litestar-fullstack/blob/e2787b0788469a99faa321818591a088515a2d6d/src/app/lib/settings.py#L386

I'm a bit confused about the purpose of the @lru_cache decorator in this template. Looks like the load_settings function is only ever called once wherever settings is imported. I could maybe see a purpose if it was used as a dependency as it is in fastapi. Perhaps I don't know something about lru_cache. Could you please elucidate the reason it is used there?

Bug: `app database upgrade` command not working

Description

I've tried to setup this template and play a little bit with the commands. It seems that app database upgrade command does not work because the signature of one of the method is invalid.

I'm going to create a pull request for this.

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Clone the repository
2. run "make install"
3. run "app database upgrade"

Screenshots

No response

Logs

>> app database upgrade
Using Litestar app from env: 'app.asgi:app'
Cannot read Vite manifest file at /home/tevak/dev/litestar-fullstack/src/app/domain/web/public/manifest.json. Did you forget to build your assets?
Starting database upgrade process ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Are you sure you you want migrate the database to the `head` revision? [y/n]: y
DEBUG - 2024-03-23 12:59:39,864 - asyncio - selector_events - Using selector: EpollSelector
......
sqlite3.Connection object at 0x6fff0ee863e0>) completed
Traceback (most recent call last):
  File "/home/tevak/dev/litestar-fullstack/.venv/bin/app", line 8, in <module>
    sys.exit(run_cli())
             ^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/src/app/__main__.py", line 26, in run_cli
    run_litestar_cli()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/litestar/__main__.py", line 6, in run_cli
    litestar_group()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/litestar/cli/_utils.py", line 273, in wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/litestar/cli/_utils.py", line 273, in wrapped
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/advanced_alchemy/extensions/litestar/cli.py", line 109, in upgrade_database
    alembic_commands.upgrade(revision=revision, sql=sql, tag=tag)
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/advanced_alchemy/alembic/commands.py", line 92, in upgrade
    return migration_command.upgrade(config=self.config, revision=revision, tag=tag, sql=sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/command.py", line 403, in upgrade
    script.run_env()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/tevak/dev/litestar-fullstack/src/app/db/migrations/env.py", line 143, in <module>
    asyncio.run(run_migrations_online())
  File "/home/tevak/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/tevak/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/src/app/db/migrations/env.py", line 135, in run_migrations_online
    await connection.run_sync(do_run_migrations)
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/engine.py", line 880, in run_sync
    return await greenlet_spawn(fn, self._proxied, *arg, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 186, in greenlet_spawn
    result = context.switch(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/src/app/db/migrations/env.py", line 106, in do_run_migrations
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/runtime/environment.py", line 948, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 605, in run_migrations
    heads = self.get_current_heads()
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 538, in get_current_heads
    if not self._has_version_table():
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/runtime/migration.py", line 555, in _has_version_table
    return sqla_compat._connectable_has_table(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/alembic/util/sqla_compat.py", line 301, in _connectable_has_table
    return inspect(connectable).has_table(tablename, schemaname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/reflection.py", line 429, in has_table
    return self.dialect.has_table(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in has_table
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/reflection.py", line 97, in cache
    ret = fn(self, con, *args, **kw)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/base.py", line 2150, in has_table
    info = self._get_table_pragma(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/base.py", line 2771, in _get_table_pragma
    cursor = connection.exec_driver_sql(statement)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1782, in exec_driver_sql
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1842, in _execute_context
    self._autobegin()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 796, in _autobegin
    self.begin()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 864, in begin
    self._transaction = RootTransaction(self)
                        ^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2684, in __init__
    self._connection_begin_impl()
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2702, in _connection_begin_impl
    self.connection._begin_impl(self)
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1107, in _begin_impl
    self.dispatch.begin(self)
  File "/home/tevak/dev/litestar-fullstack/.venv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 497, in __call__
    fn(*args, **kw)
TypeError: DatabaseSettings.get_engine.<locals>._sqla_on_begin() missing 1 required positional argument: '_'


### Package Version

2..7.0

### Platform

- [X] Linux
- [ ] Mac
- [ ] Windows
- [ ] Other (Please specify in the description above)

Bug: running "make lint" reformats the code

Description

Running make lint seems to format the code.

After a make lint, the following files are modified:

	modified:   src/app/cli.py
	modified:   src/app/contrib/aiosql/service.py
	modified:   src/app/contrib/vite/config.py
	modified:   src/app/contrib/vite/loader.py
	modified:   src/app/domain/accounts/controllers/accounts.py
	modified:   src/app/domain/accounts/guards.py
	modified:   src/app/domain/accounts/services.py
	modified:   src/app/domain/plugins.py
	modified:   src/app/domain/tags/controllers.py
	modified:   src/app/domain/teams/guards.py
	deleted:    src/app/domain/web/public/.gitkeep
	modified:   src/app/lib/db/base.py
	modified:   src/app/lib/db/migrations/versions/2023-07-14_initial_models_ddc1b07aa56f.py
	modified:   src/app/lib/dependencies.py
	modified:   src/app/lib/dto.py
	modified:   src/app/lib/repository.py
	modified:   src/app/lib/service/sqlalchemy.py
	modified:   src/app/lib/settings.py
	modified:   src/app/lib/worker/controllers.py
	modified:   src/app/lib/worker/info.py
	modified:   src/app/lib/worker/plugin.py
	modified:   src/app/utils.py
	modified:   tests/conftest.py
	modified:   tests/docker_service.py
	modified:   tests/integration/conftest.py
	modified:   tests/integration/test_access.py
	modified:   tests/integration/test_accounts.py
	modified:   tests/integration/test_teams.py
	modified:   tests/unit/lib/test_crypt.py
	modified:   tests/unit/lib/test_db.py
	modified:   tests/unit/lib/test_dependencies.py
	modified:   tests/unit/test_cli.py

I think it's too surprising to have a "make lint" action reformat the code.

URL to code causing the issue

No response

MCVE

No response

Steps to reproduce

Type `make lint`

Screenshots

No response

Logs

No response

Litestar Version

The one specified in the project

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Bug: standalone packaging issues

Description

Hi, I was looking for references to make a standalone litestar (trying to avoid rewriting part of our backend in node for our electron app) and I ran across a few issues. I'd be happy to make a PR with fixes based on feedback.

  • jsbeautifier only has a source distribution see here. This conflicts with the "PYAPP_PIP_EXTRA_ARGS": "--only-binary :all:" setting. jsbeautifier seems to be a requirement for the cli dependencies. We can remove the extra args for now, but binary only is a good sanity check for making sure that clients can install without a build toolchain. So it would be nice to have a binary only install possible. We could also specify the the format control but but it doesn't seem to support :all: + explicit excludes pip issue. Only explicit includes, so we would have to explicitly set all the deps for binary only which would be a pita unless there's a programmatic way of doing it.
  • The export of the requirements.txt is not required if you have a wheel file which is the current default. We can maybe leave those lines as a comment. I personally use hatch which doesn't have an equivalent export.
  • wget and tar subprocess calls are not generally portable (cuz of windows), and the standalones created by pyapp is platform specific without cross compilation. We should use equivalent python stdlib functionality to do those steps (urllib.request and tarfile resp.)

P.S. I didn't run the repo, I was taking parts of it for inspiration. But as far as I can tell, these all affect the main repo.

URL to code causing the issue

https://github.com/litestar-org/litestar-fullstack/blob/main/scripts/post-builds.py

MCVE

# Your MCVE code here

Steps to reproduce

steps for jsbeautifier issue.

1 - compile pyapp (suceeds)
2 - run pyapp, fails at env resolution

Screenshots

"In the format of: ![SCREENSHOT_DESCRIPTION](SCREENSHOT_LINK.png)"

Logs

*** jsbeautifier conflict log ***

The conflict is caused by:
    litestar[standard] 2.8.3 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.8.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.8.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.8.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.7.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.7.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.7.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.6.4 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.6.3 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.6.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.6.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.6.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.5 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.4 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.3 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.5.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.5 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.4 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.3 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.4.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.3.2 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.3.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.3.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.2.1 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.2.0 depends on jsbeautifier; extra == "standard"
    litestar[standard] 2.1.1 depends on jsbeautifier; extra == "cli" or extra == "standard" or extra == "full"
    litestar[standard] 2.1.0 depends on jsbeautifier; extra == "cli" or extra == "standard" or extra == "full"
    litestar[standard] 2.0.1 depends on jsbeautifier; extra == "cli" or extra == "standard" or extra == "full"
    litestar[standard] 2.0.0 depends on jsbeautifier; extra == "cli" or extra == "standard" or extra == "full"

Package Version

All

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Bug: `app users promote-to-superuser` command not working

Description

It seems that app users promote-to-superuser command does not work because it tries to use __dict__ method which does not exist instead of using to_dict() method.

I'm going to create a pull request for this.

URL to code causing the issue

No response

MCVE

No response

Steps to reproduce

1. Clone the repository
2. run "make install"
3. run `app users promote-to-superuser --email "[email protected]"`

Screenshots

No response

Logs

app users promote-to-superuser --email "[email protected]"
Using Litestar app from env: 'app.asgi:app'
────────────────────────────────────────────────────────────────────────────────────────── Promote user to superuser. ───────────────────────────────────────────────────────────────────────────────────────────
Promoting user: %[email protected]
Traceback (most recent call last):
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/bin/app", line 8, in <module>
    sys.exit(run_cli())
             ^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/__main__.py", line 23, in run_cli
    run_litestar_cli()
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/litestar/__main__.py", line 6, in run_cli
    litestar_group()
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/rich_click/rich_command.py", line 126, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/cli/commands.py", line 154, in promote_to_superuser
    anyio.run(_promote_to_superuser, email)
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_core/_eventloop.py", line 73, in run
    return async_backend.run(func, args, {}, backend_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2001, in run
    return runner.run(wrapper())
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1989, in wrapper
    return await func(*args)
           ^^^^^^^^^^^^^^^^^
  File "/home/tevak/dev/litestar-fullstack/backend/src/app/cli/commands.py", line 146, in _promote_to_superuser
    data=user_in.__dict__,
         ^^^^^^^^^^^^^^^^
AttributeError: 'UserUpdate' object has no attribute '__dict__'. Did you mean: '__dir__'?
(.venv)  ✘ tevak@tuxedo  ~/dev/litestar-fullstack/backend   main LOCAL  app users promote-to-superu

Package Version

2.7.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Enhancement: Migrate to `pdm`

Hello, in the repository of the hello world example, I saw that you migrated from poetry to pdm. Is the same migration of this template planned?

I write through a translator.

Mypy Type Error due to Recent Changes to Litestar Middleware

New issue has surfaced due to the new changes to the litestar exception middleware handling that has been merged in litestar-org/litestar@8828401 here leading to a mypy failure on pre-commit

Screenshot 2023-08-06 at 11 12 41 PM

Issue on Line 120 where create_exception_response is expecting two arguments, with the first one being of type Request[Any, Any, Any] and the second being an exception. However, in the previous version only the exception is being passed.

Screenshot 2023-08-06 at 11 14 07 PM

Reference new middleware implementation from litestar:
Screenshot 2023-08-06 at 11 24 01 PM

Bug: not compatible with any stable version of Litestar

Description

Tests fail when updated to either Litestar 2.0.0 or 2.1.0.

URL to code causing the issue

No response

MCVE

No response

Steps to reproduce

1. Update litestar to either 2.0.0 or 2.1.0
2. Run `make test`

Screenshots

No response

Logs

No response

Litestar Version

2.0.0 or 2.1.0

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Question about starting this repo.

Hi There,

i wanted to take a look at this repo and start the project locally.
however i am running into an issue. of which im not sure if im doing it correctly.

im trying to start the application with: uvicorn app.asgi:run_app --reload
but that seems to be stuck on waiting for application startup.

INFO: Will watch for changes in these directories: ['/home/donnyio/git/starlite-full-stack-example']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [81115] using WatchFiles
WARNING: ASGI app factory detected. Using it, but please consider setting the --factory flag explicitly.
INFO: Started server process [81117]
INFO: Waiting for application startup. <-------------------

Enhancement: Complete UI

Summary

UI should implement the functionality to call APIs

  • Signup
  • Login
  • Profile
  • Teams
  • Team Members & Invitations

Basic Example

No response

Drawbacks and Impact

No response

Unresolved questions

No response

App CLI not working

Are there any requirements to make the app CLI work? I'm getting the following errors when trying to run any "app" command.
image

Enhancement: Optimize database testing pipeline

Description

I've been working with this framework for a while and added around 300 tests. On my machine, it currently takes 18 minutes to run all 300 tests, that is quite unacceptable.

I've checked what takes this long and discovered that, in the test setup:

  • the create_app() call, in @pytest.fixture(name="app") takes 1s
  • seeding the db takes 1.25s (the db currently has 32 models)

This means that to run 300 tests, the system needs 11+ minutes just to create the app and seed the db (62% of the execution time), that arguably can be done once at the beginning instead of each time.

Screenshots

image

Litestar Version

2.0.1

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Docs: Refactor documentation

Summary

The documentation for this project needs an overhaul and should align with the existing Litestar branding.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.